Reputation: 81
I'm trying to change the action bar background color of an activity that extends ActionBarActivity. So far my styles.xml looks like this
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">#ff2b8bff</item>
</style>
And I call on the style in my manifest like this
android:theme="@style/AppTheme"
The problem is that the action bar is always grey,it never changes to the color I have specified.I know there is a lot of information on questions like this already but none of them have worked for me.I'm just wondering what it is I am missing.
Upvotes: 0
Views: 403
Reputation: 220
This should do:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/red</item>
<item name="background">@color/red</item>
</style>
From here.
Upvotes: 1
Reputation: 2691
The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending
ActionBarActivity
which requires theAppCompat
theme to be applied.Change the Java inheritance from
ActionBarActivity
toActivity
and leave the dialog theme in the manifest as it is.
Source: https://stackoverflow.com/a/21815015/3498044
Upvotes: 0