In my case, I also used the following approach:
@Override public void onStart() { super.onStart(); getDialog().getWindow().setLayout(LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.dialog_height)); } }
But there were still small spaces between the left and right edges of the dialog and the edges of the screen on some Lollipop + devices (for example, Nexus 9).
This was not obvious, but finally, I realized that for the full width for all devices and platforms, the background of the background should be specified inside styles.xml, as shown below
<style name="Dialog.NoTitle" parent="Theme.AppCompat.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:padding">0dp</item> <item name="android:windowBackground">@color/window_bg</item> </style>
And, of course, this style needs to be used when we create a dialog as follows:
public static DialogFragment createNoTitleDlg() { DialogFragment frag = new Some_Dialog_Frag(); frag.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog_NoTitle); return frag; }
goRGon Jul 23 '15 at 20:55 2015-07-23 20:55
source share