Search code examples
androidactionbarsherlockandroid-theme

How to change color of the action bar using actionbarsherlock


I'm trying to change color of the action bar across the board in my app. I found this answer which suggests a way to do it. So I've created a themes.xml file under res/values folder with the following:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.MyTheme" parent="Theme.Sherlock.ForceOverFlow">
        <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
    </style>

    <style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="android:background">#fff4231e</item>
        <item name="background">#fff4231e</item>
    </style>
</resources>

However, I get an error in the above code:

Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.ForceOverFlow'.

in my build.gradle I have the following:

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

I am using AndroidStudio and Gradle


Solution

  • ActionBarSherlock version 4.4 does not include the ForceOverflow themes, it was removed in 4.2. You will need to use an older version of ABS to use ForceOverflow as a theme.

    As per the Change Log :

    Fix: Remove .ForceOverflow themes. These never should have been included.

    If you don't actually need the ForceOverflow, you could use Theme.Sherlock, see the official page for details :

    <style name="Theme.MyTheme" parent="Theme.Sherlock">
        <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
    </style>