title: Android custom toolbar overlapping status bar : how to resolve it
body: <p>I am working with the project for android app.</p>
  
  <p>My code below :</p>
  
  <p>My <strong>activity_mainmenu.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawerLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".MainActivity"&gt;
      &lt;RelativeLayout xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:background="#ff8400"&gt;
          &lt;ListView
              android:id="@+id/list_view_push"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"/&gt;
  
          &lt;include android:id="@+id/toolbar" layout="@layout/include_toolbar"/&gt;
  
          &lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_below="@id/toolbar"&gt;
          &lt;/android.support.v4.view.ViewPager&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>My <strong>toolbar</strong></p>
  
  <pre><code>&lt;android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:fitsSystemWindows="true"
      android:elevation="4dp"
      android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;FrameLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TextView
              android:id="@+id/toolbar_title"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_gravity="left"
              android:gravity="center_vertical"
              android:text="@string/app_name"
              style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" /&gt;
          &lt;TextView
              android:id="@+id/toolbar_audio"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_gravity="right"
              android:layout_marginRight="80dp"
              android:gravity="center_vertical"
              android:textColor="@color/background_gradient_start"
              android:text="@string/audio"
              android:visibility="gone"/&gt;
          &lt;TextView
              android:id="@+id/toolbar_video"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_gravity="right"
              android:layout_marginRight="10dp"
              android:gravity="center_vertical"
              android:textColor="@color/background_gradient_start"
              android:text="@string/video"
              android:visibility="gone"/&gt;
          &lt;RadioButton
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:text="Audio"
                  android:layout_gravity="right"
                  android:layout_marginRight="80dp"
                  android:id="@+id/radioButtonAudio"
                  android:checked="true"
                  android:buttonTint="@color/background_gradient_start"/&gt;
          &lt;RadioButton
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:text="Video"
                  android:id="@+id/radioButtonVideo"
                  android:layout_gravity="right"
                  android:layout_marginRight="10dp"
                  android:gravity="center_vertical"
                  android:checked="false"
                  android:buttonTint="@color/background_gradient_start"/&gt;
      &lt;/FrameLayout&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>And <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;application
          android:name="............AppController"
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/UAmpAppTheme" &gt;
          &lt;!--This meta-data tag is required to use Google Play Services.--&gt;
          &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/&gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" 
              android:screenOrientation ="portrait" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>With <strong>android:theme="@style/UAmpAppTheme"</strong></p>
  
  <pre><code>&lt;style name="UAmpAppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
          &lt;item name="android:statusBarColor"&gt;@android:color/transparent&lt;/item&gt;
          &lt;item name="android:windowDrawsSystemBarBackgrounds"&gt;true&lt;/item&gt;
          &lt;item name="android:windowTranslucentStatus"&gt;true&lt;/item&gt;
          &lt;item name="android:windowContentTransitions"&gt;true&lt;/item&gt;
  
          &lt;item name="colorPrimary"&gt;#ffff5722&lt;/item&gt;
          &lt;item name="colorPrimaryDark"&gt;#ffbf360c&lt;/item&gt;
          &lt;item name="colorAccent"&gt;#ffff5722&lt;/item&gt;
      &lt;/style&gt;
  </code></pre>
  
  <p>And :</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_mainmenu);
      initializeToolbar();
  </code></pre>
  
  <h2>        ....................</h2>
  
  <pre><code>protected void initializeToolbar() {
          mToolbar = (Toolbar) findViewById(R.id.toolbar);
          if (mToolbar == null) {
              throw new IllegalStateException("Layout is required to include a Toolbar with id " +
                  "'toolbar'");
          }
          mToolbar.inflateMenu(R.menu.main);
  
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
              mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open_content_drawer, R.string.close_content_drawer);
              mDrawerLayout.setDrawerListener(mDrawerListener);
              mDrawerLayout.setStatusBarBackgroundColor(ResourceHelper.getThemeColor(this, R.attr.colorPrimary, android.R.color.black));
              populateDrawerItems();
              setSupportActionBar(mToolbar);
              updateDrawerToggle();
          } else {
              setSupportActionBar(mToolbar);
          }  
              //int resourceIdnavigation_bar_height = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
              //if (resourceIdnavigation_bar_height &gt; 0) {
                  //LogHelper.d("MainMenu", " Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT_WATCH  1 " + getResources().getDimensionPixelSize(resourceIdnavigation_bar_height));
              //};
  
              //int resourceIdstatus_bar_height = getResources().getIdentifier("status_bar_height", "dimen", "android");
             // if (resourceIdstatus_bar_height &gt; 0) {
                  //LogHelper.d("MainMenu", " Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT_WATCH  2 " + getResources().getDimensionPixelSize(resourceIdstatus_bar_height));
             // }
  
          mToolbarInitialized = true;
      }
  </code></pre>
  
  <p><strong>I have a problem with Custom action toolbar:</strong></p>
  
  <ul>
  <li><strong>custom toolbar overlapping below status bar</strong></li>
  </ul>
  
  <p>How to resolve it.</p>
  
  <p>See image : <a href="https://i.stack.imgur.com/Ajd6F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ajd6F.jpg" alt="enter image description here"></a></p>
  
  <p>This issue happen with (<strong>Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.KITKAT_WATCH</strong>)</p>
  
  <p>This issue not happen with (<strong>Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH</strong>)</p>
  
  <p>see image : <a href="https://i.stack.imgur.com/K9iMY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K9iMY.png" alt="enter image description here"></a></p>
  
  <p>Thanks</p>