Im trying to display an DialogFragment with match_parent both for height and width but it happens that on top the DialogFragment is being displayed below StatusBar.
The DialogFragment is applying some default value for padding on bottom, right, left, and top. But the top padding should start counting from statusBar and not from the total screen size.
How can I set DialogFragment to be match_parent, but have the normal/default padding on top,bottom,right,left?
By default
Dialogwould be appliedFLAG_LAYOUT_IN_SCREENandFLAG_LAYOUT_INSET_DECORflags. An excerpt fromPhoneWindow:FLAG_LAYOUT_INSET_DECORis the flag, that you do not want to be applied. From docs:By default,
windowIsFloatingis enabled. So, if you declare your custom theme:Then in your
DialogFragment:Where the layout content is following:
Then you'll get this output:
If you want the pink layout to be laid out below status bar and above navigation bar, then just apply
android:fitsSystemWindows="true"to your rootViewGroup:This will be the output:
You can see the meaning of that flag in my this answer.