There is a transparent DialogFragment.
public class TempFragment extends DialogFragment { static TempFragment newInstance() { TempFragment dialogFragment = new TempFragment(); return dialogFragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_block_dialog, container, false); return v; } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); final Drawable drawable = new ColorDrawable(-15108398); drawable.setAlpha(200); dialog.getWindow().setBackgroundDrawable(drawable); dialog.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE); return dialog; } @Override public void onStart() { super.onStart(); getDialog().getWindow().setLayout(1000, 1500); } } Layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/block_dialog_layout" style="@android:style/Theme.Dialog" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="8dp" android:text="@string/hello_blank_fragment" android:textAppearance="?android:attr/textAppearanceSmall" /> <Button android:id="@+id/show" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Click" android:textAppearance="?android:attr/textAppearanceSmall" /> <Button android:id="@+id/show2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Click" android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout> In these lines:
getDialog().getWindow().setLayout(1000, 1500); I hardcoding extends DialogFragment , since this does not make it turn out very narrow. How to properly expand DialogFrgment (not hardcoded) - so that it will turn out the same as in this code, that is, it would occupy almost the entire screen, but leaving the framework, just like a normal Dialog (with Title)).
Can do as the DialogFragment itself expands (when the Title is not deleted by the user)?
I need it without a title, I delete it dialog.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE); while Dialog is narrowed to the maximum ...