简体   繁体   中英

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM