Question

I need to show a DialogFragment on top of an existing normal Activity (non fullscreen and with ActionBar visible).
My DialogFragment needs to be in fullscreen, so I'm using the following lines to achieve that result:

getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);

On ICS everything works fine, my DialogFragment is shown in fullscreen and when I close it my Activity content haven't been resized so there is no layout glitches (as it should since the fullscreen flag I'm setting should affect only the window where the DialogFragment resides).

On Jelly Bean instead when I close my DialogFragment I see that my Activity content was resized to cover also the statusbar and so there is a layout glitch when it tries to return to the original size.
I think this may be related to the introduction of the new system UI flags (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, etc) but I couldn't figure out how to have the same ICS behavior also on Jelly Bean... Any idea?

Was it helpful?

Solution

Found a workaround, you need to call:

view.setFitsSystemWindows(true);

before setting the fullscreen flag to your window, and in the same way:

view.setFitsSystemWindows(false);

before clearing it.

view must be a View inside your Activity (not your DialogFragment!) and it must be visible (see setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) does not work)

Still, there are some glitches when animating the dismiss of the DialogFragment that are not present on ICS... But I think that's another issue...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top