2

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

Community
  • 1
  • 1
Anthony
  • 33,838
  • 42
  • 169
  • 278
  • If you're using Eclipse, I sometimes get weird parsing errors when editing my style.xml files. Have you tried opening the Problems window, deleting the error message, and trying a rebuild of the project? -- Also, if you're using 4.2.0 or above then apparently it's been removed: http://stackoverflow.com/a/13180285/1426565 – Cruceo Feb 25 '14 at 17:09

1 Answers1

1

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>
2Dee
  • 8,609
  • 7
  • 42
  • 53
  • hmmm I wonder what are the options to change color of action bar after 4.4 then. – Anthony Feb 25 '14 at 17:14
  • That gets the code compiled and running, however, the color of the action bar is still the same. I even added `setTheme(R.style.Theme_MyTheme)` in `onCreate` of all my activity. – Anthony Feb 25 '14 at 17:34
  • 1
    Are you setting the same theme in all styles.xml files ? If you have several styles.xml for different versions (contained, for example in values, values-v11, values-v14, ...), you won't see the theme on the test device if it's running a newer version until you modify those as well... You could also try removing the alpha (just using #f4231e for the color) although I doubt that it could be causing the problem. Calling setTheme is not needed, just having android:theme="@style/Theme.MyTheme" under the application node in the Manifest should work. – 2Dee Feb 25 '14 at 17:50