title: Dark theme not applied correctly, statusbar color unchanged
body: <p>I am trying to create a <strong>light</strong> and <strong>dark</strong> theme for my application.
  When applying the light theme the statusbar is orange as it should be but as soon as I <em>switch to the dark theme</em> the <strong>statusbar</strong> stays orange although <strong>I want it to be black.</strong></p>
  
  <p>I am not a pro in theming so any help is really appreciated.</p>
  
  <p>I included some screenshots, so you can see what I mean.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><strong>I found a solution myself</strong> (should somebody else have the same problem), in the beginning of my Loginactivity I check which theme is applied through a SharedPrefs file.</p>
  
  <pre><code>// which theme is set.
          SharedPreferences settings = getSharedPreferences(Helper.PREF_NAME, MODE_PRIVATE);
          Helper.newTheme = settings.getInt("themeCustom", 0);
  </code></pre>
  
  <p>If the black theme is set, then I just modify the statusbar myself with the WindowManager:</p>
  
  <pre><code>if (Helper.newTheme == Helper.THEME_DARK) {
  
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
                  Window window = getWindow();
                  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                  window.setStatusBarColor(Color.parseColor("#1B1C1C"));
              }
  
              this.setTheme(R.style.DarkTheme);
       ===
  }
  </code></pre>
  
  <p>Case closed..</p>
  
  <p><a href="https://i.stack.imgur.com/JlobX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JlobX.jpg" alt="Light Theme"></a></p>
  
  <p><a href="https://i.stack.imgur.com/XVvRF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XVvRF.jpg" alt="Dark Theme"></a></p>
  
  <p>Styles.xml:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;!-- reference to CardView White/Dark styles --&gt;
      &lt;attr name="cardStyle" format="reference" /&gt;
      &lt;attr name="txtBgStyle" format="reference" /&gt;
  
      &lt;!-- Light application theme. --&gt;
      &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
          &lt;!--   your app branding color for the app bar --&gt;
          &lt;item name="colorPrimary"&gt;#FD8300&lt;/item&gt;
          &lt;!--   darker variant for the status bar and contextual app bars --&gt;
          &lt;item name="colorPrimaryDark"&gt;#F59F00&lt;/item&gt;
          &lt;!--   theme UI controls like checkboxes and text fields --&gt;
          &lt;item name="colorAccent"&gt;#FF4081&lt;/item&gt;
          &lt;item name="android:windowDisablePreview"&gt;true&lt;/item&gt;
          &lt;!-- v7.widget.CardView background color --&gt;
          &lt;item name="cardStyle"&gt;@style/CardView.Light&lt;/item&gt;
          &lt;item name="txtBgStyle"&gt;@style/CardView.Light&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;!-- Dark application theme. --&gt;
      &lt;style name="DarkTheme" parent="Theme.AppCompat"&gt;
          &lt;!--   your app branding color for the app bar --&gt;
          &lt;item name="colorPrimary"&gt;#FD8300&lt;/item&gt;
          &lt;!--   darker variant for the status bar and contextual app bars --&gt;
          &lt;item name="colorPrimaryDark"&gt;#1B1C1C&lt;/item&gt;
          &lt;!--   theme UI controls like checkboxes and text fields --&gt;
          &lt;item name="colorAccent"&gt;#FAFAFA&lt;/item&gt;
          &lt;!-- v7.widget.CardView background color --&gt;
          &lt;item name="cardStyle"&gt;@style/cardStyle&lt;/item&gt;
          &lt;item name="txtBgStyle"&gt;@style/txtBgStyle&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;!-- v7.widget.CardView dark style --&gt;
      &lt;style name="cardStyle"&gt;
          &lt;!-- Card background color --&gt;
          &lt;item name="cardBackgroundColor"&gt;#282929&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;!-- Custom dark style for textviews, layouts, etc --&gt;
      &lt;style name="txtBgStyle"&gt;
          &lt;item name="android:background"&gt;#282929&lt;/item&gt;
      &lt;/style&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;style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
  
      &lt;style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /&gt;  
  &lt;/resources&gt;
  </code></pre>
  
  <p>Styles v21:</p>
  
  <pre><code>&lt;resources&gt;&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;item name="android:windowDrawsSystemBarBackgrounds"&gt;true&lt;/item&gt;
          &lt;item name="android:statusBarColor"&gt;@android:color/transparent&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="myapp.example.com.myapp"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".LoginActivity"
              android:noHistory="true"&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;activity
              android:name=".MainActivity"
              android:noHistory="false"
              android:label="@string/title_activity_login"/&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>