title: Android 5.0 translucent status bar
body: <p>Going from <a href="https://developer.android.com/training/material/theme.html#StatusBar" rel="nofollow">https://developer.android.com/training/material/theme.html#StatusBar</a>, I have had tons of different trials and errors on how to get status bar transparent, but not much luck.</p>
  
  <p>I do not want navigation drawer, just a plane and simple activity with translucent status bar like they are showing on <a href="http://www.google.com/design/spec/style/imagery.html#imagery-best-practices" rel="nofollow">http://www.google.com/design/spec/style/imagery.html#imagery-best-practices</a></p>
  
  <p>Here is my design</p>
  
  <pre><code>        &lt;style name="AppTheme" parent="android:Theme.Material.NoActionBar"&gt;
          &lt;!-- All customizations that are NOT specific to a particular API-level can go here. --&gt;
          &lt;item name="android:windowActionBar"&gt;false&lt;/item&gt; 
                  &lt;!--   your app branding color for the app bar --&gt;
          &lt;item name="android:colorPrimary"&gt;@android:color/transparent&lt;/item&gt;
          &lt;!--   darker variant for the status bar and contextual app bars --&gt;
          &lt;item name="android:colorPrimaryDark"&gt;@android:color/transparent&lt;/item&gt;
          &lt;item name="android:statusBarColor"&gt;@android:color/transparent&lt;/item&gt;
                  &lt;item name="android:fitsSystemWindows"&gt;true&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:windowTranslucentNavigation"&gt;true&lt;/item&gt;
                       &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt; 
           &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
  &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
  
  
      &lt;/style&gt;
  </code></pre>
  
  <p>and code in java</p>
  
  <pre><code>        getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
              WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      getWindow().getAttributes().flags &amp;= (~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      getWindow().setStatusBarColor(Color.TRANSPARENT);
  
      getWindow().getDecorView().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
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE);
  </code></pre>
  
  <p>I have gone through a lot of stackoverflow answers, including using ScrimInsetsFrameLayout, but nothing seem to achieve something as simple as following the exact rules</p>
  
  <blockquote>
    <p>You can also draw behind the status bar yourself. For example, if you want to show the status bar transparently over a photo, with a subtle dark gradient to ensure the white status icons are visible. To do so, set the android:statusBarColor attribute to @android:color/transparent and adjust the window flags as required. You can also use the Window.setStatusBarColor() method for animations or fading.  Note: The status bar should almost always have a clear delineation from the primary toolbar, except for cases where you show edge-to-edge rich imagery or media content behind these bars and when you use a gradient to ensure that the icons are still visible.</p>
  </blockquote>