Problems with immersive mode in Android

I am developing an application that can be in two modes: the default mode with an action bar and full screen. The user can switch from the default mode to full screen and vice versa. And now I want to hide the buttons of the software system on the tabs running Android KitKat and older. For this, I use the dive mode. When the user switches to full screen mode, I run this code:

mDecorView.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 // hide nav bar
        | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
        | View.SYSTEM_UI_FLAG_IMMERSIVE);

When the user switches to normal mode, I run this code:

 mDecorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

The first problem is that when I switch to dive mode, my view does not resize, and I can see part of the background of my window instead of soft buttons (Figure 1).

enter image description here

, , , , . ( 2)

enter image description here

+4

Source: https://habr.com/ru/post/1568173/


All Articles