I have a dialogfragment I am using to select from a list. I have this in fullscreen, and it has always worked prior to 11/ API 30. However, now in 11 it started appearing with the classic "not in fullscreen" look, where you can see the layout behind it on all four sides.
I got it working again by overriding the onCreateDialog method, see below. In that method, I basically duplicate the calls I already make in onStart().
My question is WHY DID I HAVE TO DO THIS? It works fine prior to version 11/30, and i haven't found any documentation that mentions any changes related to this in 11.
New method I had to add:
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return dialog;
}
My onStart that made the window appear normal prior to 11:
public void onStart() {
super.onStart();
Window window = getDialog() != null ? getDialog().getWindow() : null;
if (window != null) {
if (windowAnimStyle > 0) {
window.getAttributes().windowAnimations = windowAnimStyle;
}
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}
this works for me on the sdk 30
<style name="FullScreenDialogStyle">
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">false</item>
</style>
override onCreate in your DialogFragment subclass
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.FullScreenDialogStyle)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With