Reputation: 29867
My Android app uses a minimum SDK version 15. I am trying to change the background color of the Actionbar and want to do this by changing the style and theme. I've tried many things but the background remains dark. Here is what my styles look like:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#eeeeee</item>
</style>
In my manifext I set the application's theme to AppTheme.
Upvotes: 0
Views: 114
Reputation: 1431
By default AppCompat support library uses value of colorPrimary
attribute as a color of ActionBar
.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#eeeeee</item>
</style>
But if you want to make color of ActionBar
be independent from primary color of theme, then you can set it like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="background">@color/primary_teal_500</item>
</style>
Upvotes: 1
Reputation: 3688
Modify your style.xml file as follows and try,
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#eeeeee</item>
</style>
And your menifest as follows,
android:theme="@style/AppTheme" >
Upvotes: 0
Reputation: 12358
When using the Support Library, define the action bar like this:
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@drawable/actionbar_background</item>
</style>
</resources>
Then apply your theme to your entire app or individual activities:
<application android:theme="@style/CustomActionBarTheme" ... />
Upvotes: 0
Reputation: 1745
Use colorPrimary and colorPrimaryDark
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/LightColor</item>
<item name="colorPrimaryDark">@color/DarkColor</item>
</style>
Upvotes: 0