1

I'm implementing immersive mode using this code:

        activity.getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE
        );

But the problem is as I scroll the recycler view, the status and navigation bar are shown as an item view reaches the top. It's hard to explain but here's the gif:

https://giphy.com/gifs/xT4uQiBlagrD9ljQqc

Note that as an item view approaches the top, the status bar is shown (only the dark background is shown though). Note also the navigation bar as an item view's bottom reaches the boundary of the navigation bar (notice the gray background at the bottom).

This happens for every item in the recycler view which is really annoying.

Sid Go
  • 2,041
  • 3
  • 16
  • 29

1 Answers1

0

It's missing you some UI options like immersive sticky. Here's my working ui options:

View decorView = getWindow().getDecorView();
int uiOptions =  View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_FULLSCREEN
        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
Tunaki
  • 132,869
  • 46
  • 340
  • 423
firetrap
  • 1,947
  • 3
  • 24
  • 39