title: Android NavigationDrawer overlap by status bar
body: <p>I've seen a lot questions about having a translucent status bar on top of navigation bar like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Qgs0U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qgs0U.png" alt="enter image description here"></a></p>
  
  <p>But what I want to achieve is to have a non-translucent status bar and make navigation drawer header view same height as action bar. This works find for pre-lollipop devices (API &lt; 21). But for API 21+, the entire navigation drawer just moved up and overlapped by status bar, instead of place below status bar. The only work around I can think of is to manually set <code>layout_marginTop</code> on the header view for devices later than API 21+. Is there a better solution to fix this for all devices?</p>
  
  <p>API &lt; 21:</p>
  
  <p><a href="https://i.stack.imgur.com/Cosgz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cosgz.png" alt="enter image description here"></a></p>
  
  <p>API > 21:</p>
  
  <p><a href="https://i.stack.imgur.com/3acKe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3acKe.png" alt="enter image description here"></a></p>
  
  <p>styles.xml(v21):</p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppTheme.NoActionBar"&gt;
          &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
          &lt;item name="windowNoTitle"&gt;true&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>DrawerLayout:</p>
  
  <p>
      </p>
  
  <pre><code>    &lt;include
          layout="@layout/app_bar_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="false"
          app:headerLayout="@layout/nav_header_main"
          app:menu="@menu/activity_main_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>I've tried to set <code>fitsSystemWindows</code> to both <code>true</code> or <code>false</code>. No changes.</p>
  
  <p>Here is my hack solution when initialize navigation drawer (and this is also answered by @AkashBhave):</p>
  
  <pre><code>    LinearLayout navigationHeader = (LinearLayout) navigationView.getHeaderView(0);
      if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.LOLLIPOP) {
          // This is make sure navigation header is below status bar
          // This only required for devices API &gt;= 21
          LinearLayout.LayoutParams layoutParams =
                  (LinearLayout.LayoutParams) navigationHeader.getLayoutParams();
          layoutParams.setMargins(0, getStatusBarHeight(), 0, 0);
          navigationHeader.setLayoutParams(layoutParams);
      }
  </code></pre>