title: Changing Android app's status bar color but keep translucency
body: <p>For an app I'm building, I used the <a href="http://android-developers.blogspot.nl/2015/05/android-design-support-library.html" rel="nofollow noreferrer">Design Support Library</a>.
  I created an app that uses a <code>TabLayout</code>. A little feature of the app is that when the user changes tabs, the color of both the <code>TabLayout</code> and the <code>Toolbar</code> change to a corresponding color. We're also using the new <code>NavigationView</code>, to present the user with a Material design <code>DrawerLayout</code>.</p>
  
  <p>However, changing the color of both the <code>TabLayout</code> and the <code>Toolbar</code> is no problem at all, we do it in the lines of the following;</p>
  
  <pre><code>String hexColor = String.format("#%06X", (0xFFFFFF &amp; getResources().getColor(R.color.primaryColor)));
  getBaseActivity().getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(hexColor)));
  mTabLayout.setBackgroundColor(getResources().getColor(primaryColor));
  </code></pre>
  
  <p>This is all good, and working like it's supposed to. The problem appears when I try to set the <code>Status bar</code> background. Since the material design specification tells us that the <code>NavigationDrawer</code> should get some special treatment, below image shows how the status bar is actually a form of translucent. The Navigation Drawer falls over my main fragment while the navigation bar is above both, being a translucent bar.</p>
  
  <p><img src="https://i.stack.imgur.com/kinvx.png" alt="What it should look like"></p>
  
  <p>My first thoughts were that it's just a bar with a #7000 hexadecimal value or something, but I couldn't be further from the truth. Doing that doesn't change the color of the actual color it should "darken".</p>
  
  <p>After that I just tried setting the darker version of the required color as the background for the status bar like so;</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getBaseActivity().getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(getResources().getColor(R.color.primaryColor));
  }
  </code></pre>
  
  <p>But after doing this, the complete functionality breaks. My view will look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/kXTqo.png" alt="enter image description here"></p>
  
  <p>In essence, what can I do to fix this behaviour? I'd really like to change it so that the translucency feature still does what it needs to do according to the Material design spec, but also change the <code>status bar</code>'s background color.</p>