1

I'm using a single activity - multiple fragment architecture with a bottom navigation bar. There are some fragments that use a stable layout flag, and others that use a fullscreen layout flag. However, when switching from SYSTEM_UI_FLAG_LAYOUT_STABLE to SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN (and vice versa), the content doesn't fill the screen properly - when switching to stable, the bottom is pushed down past the navigation, and when switched back to fullscreen, the content doesn't fill the screen properly. If I switch to another fullscreen fragment from that one, the issue corrects itself. I wanted to know if there was a way to keep that issue from happening in the first place.

This is the code I'm using to switch between stable and fullscreen:

fun makeFullScreen() {
    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}

fun makeStable() {
    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}

The respective functions are being called in the onResume() function of each fragment. Any help would be greatly appreciated.

You can see screenshots of the issue here: https://i.stack.imgur.com/xI6n8.jpg

Thanks

Edit 1: Just to clarify, I basically want it so that the bottom navigation bar stays in the right place at the bottom, rather than the "jumping" behavior you see in the screenshots.

  • Have you tried `activity.recreate()` when you make the switch, if nothing else works? – EpicPandaForce Oct 30 '19 at 17:35
  • That's something that I think may work, the only thing is off the top of my head I'm not sure how to do it without ending up in an infinite loop. Though I only tried calling it directly from the fragment and not from the host activity – Maurice Gaynor Oct 30 '19 at 20:46

2 Answers2

0

Try this one

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
pavel
  • 1,603
  • 22
  • 19
  • Thanks for the answer, but this doesn't seem to be helping with my issue. I also need the status bar to be displayed at all times. – Maurice Gaynor Oct 30 '19 at 17:30
0

After a ton of searching (I've looked up this issue on and off for a few weeks now), I finally found something that works for me. The answer provided here: BottomNavigationView jumps up leaving blank space when fullscreen