How to set Full screen dialog with dialog fragment
set this line after creating dialog.
dialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
If you are creating custom DialogFragment
write this in onCreate
of your DialogFragment
:
setStyle(DialogFragment.STYLE_NORMAL,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
reference
Create theme like this and add to your dialog
<style name="ThemeDialog" parent="android:Theme.Holo.Dialog">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
set this line after creating dialog
getDialog().getWindow()
.getAttributes().windowAnimations = R.style.ThemeDialog;
WindowManager.LayoutParams wmlp = getDialog().getWindow().getAttributes();
wmlp.gravity = Gravity.FILL_HORIZONTAL;
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
Create a theme
in your style.xml
which extends from Theme.AppCompat.Light.DarkActionBar
, something like below:
<style name="DialogFragmentTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:paddingRight">0dp</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:windowNoTitle">true</item>
</style>
and set the style
you created while opening the dialog
, something like below:
CustomDialogFragment mDialog = new CustomDialogFragment();
...
mDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragmentTheme);
mDialog.show(getSupportFragmentManager(), "DialogFragment");