Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ActionBar not changing background color

I am trying to change the background color of my action bar but it doesnt change. My app is using the AppCompat theme if that affects anything.

Here is my theme that is being used. My app points to use this theme so that is not the problem

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBar</item>
</style>

<!-- Action Bar Styles -->
<style name="ActionBar" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/blue</item>
    <item name="background">@color/blue</item>
</style>

like image 914
Moussa Harajli Avatar asked Sep 01 '14 21:09

Moussa Harajli


People also ask

What is ActionBar in Android?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.


1 Answers

In your ActionBar style, delete the android:background, only keep the background attribute. Also make sure to implement your AppTheme in the application tag or in the activities extending the action bar in your AndroidManifest.xml file. I've also added the "@style/" attribute before Widget.AppCompat since its a default style defined in the android library.

Your code should look like this :

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBar</item>
</style>

<!-- Action Bar Styles -->
<style name="ActionBar" parent="@style/Widget.AppCompat.ActionBar">
    <item name="background">#0000ff</item>
</style>
like image 72
wheeliez Avatar answered Sep 27 '22 17:09

wheeliez