0

All I am trying to do is have the actionbar and status bar change colors to have material design. Below is the theme I have created:

 <!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="android:colorPrimary">#FF5722</item>
    <!--<item name="android:statusBarColor">#E64A19</item>-->

    <!-- colorPrimaryDark is used for the status bar -->
    <item name="android:colorPrimaryDark">#E64A19</item>


    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="android:colorAccent">#FF9800</item>

    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight & colorSwitchThumbNormal. -->

</style>

However when running the status bar changes color fine, but the action bar remains black. I know there is probably a simple answer to this but what am I missing?

This question is not a duplicate of the suggested question. Please remove flag.

ez4nick
  • 9,756
  • 12
  • 37
  • 69
  • Try changing the parent theme to `Theme.AppCompat.Light.NoActionBar` – Bidhan Jun 07 '15 at 13:03
  • possible duplicate of [Change Background color of the action bar using AppCompat](http://stackoverflow.com/questions/23155637/change-background-color-of-the-action-bar-using-appcompat) – hungryghost Jun 07 '15 at 13:09

2 Answers2

5

Since you're using AppCompat, you should use AppCompat attributes, instead of Android system attributes.

Change

android:colorPrimary

to

colorPrimary

The entire thing should look like this:

<!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#FF5722</item>

    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#E64A19</item>

    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF9800</item>
</style>
Christian Göllner
  • 5,808
  • 4
  • 19
  • 20
1

Remove android: from colorPrimary. appcompat-v7 does not use the android: prefix in its themes, last I checked.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491