How can I dynamically hide the status and the navigation bar completely?
The app contains a regular navigation drawer with a appbar / toolbar and FAB buttons.
When switching to full screen, the content of the navigation and the status bar is scrolled away. Two empty bars are left on the screen. I want those empty bars to hide.
I created a minimal demo app. On the left is the regular app. When pushing on the fab, the app should be shown fullscreen.
How can I get the bars to hide?
QUESTION: Please write which change(s) are needed in the minimal demo project?
Updated with a second solution:
The GREAT solution provided by @Roaim works. Essential was to set the android:fitsSystemWindows layout property to false.
If you still have trouble with the showing and hiding of status/navigation bars, this solutin may help you.
Hide the bars completely:
public static void hideSystemUI() {
    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();
    }
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE
                    | 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);
}
And show all bars:
public static void showSystemUI() {
    if (getSupportActionBar() != null) {
        getSupportActionBar().show();
    }
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}

 
    
 
     
     
     
    