title: Android - hide status and navigation bar completely for an app with nav drawer and app bar
body: <p>How can I dynamically hide the status and the navigation bar <strong>completely</strong>? </p>
  
  <p>The app contains a regular navigation drawer with a appbar / toolbar and FAB  buttons. </p>
  
  <p>When switching to full screen, the <strong>content</strong> 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. </p>
  
  <p>I created a <a href="https://github.com/johan974/android-fullscreen-with-drawerlayout.git" rel="noreferrer">minimal demo app</a>. On the left is the regular app. When pushing on the fab, the app should be shown fullscreen. </p>
  
  <p><a href="https://i.stack.imgur.com/UXAPz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UXAPz.png" alt="enter image description here"></a></p>
  
  <p>How can I get the bars to hide? </p>
  
  <p>QUESTION: Please write which change(s) are needed in the minimal demo project? </p>
  
  <p><strong>Updated with a second solution</strong>: </p>
  
  <p>The GREAT solution provided by @Roaim works. Essential was to set the <em>android:fitsSystemWindows</em> layout property to false. </p>
  
  <p>If you still have trouble with the showing and hiding of status/navigation bars, this solutin may help you. </p>
  
  <p>Hide the bars completely: </p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>And show all bars: </p>
  
  <pre><code>public static void showSystemUI() {
      if (getSupportActionBar() != null) {
          getSupportActionBar().show();
      }
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
  }
  </code></pre>