0

Having some trouble overriding ActionBarSherlock styles, hopefully someone can help. I have created a drawable like so:

(in res/drawable/actionbar_background.xml)

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bg"
    android:tileMode="repeat" />

Then in my app's style file (in res/values/style.xml)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="my_theme" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>
</resources>

The result is that the Theme.Sherlock.Light style is picked up (or Theme.Sherlock if I swap it), but I don't get any change in style to the actionbar's background itself.

Thanks

2 Answers 2

12

This should give you the Theme.Sherlock.Light style with your custom action bar background:

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="abBackground">@drawable/actionbar_background</item>
</style>

Put it in your res/values/style.xml file and declare your style to be @style/ActionBar in your manifest.

More info - http://actionbarsherlock.com/theming.html

2
  • Perfect, man, thanks. I swear I looked at that theming page a half dozen times w/o picking up on that.
    – Paul
    Feb 6, 2012 at 16:02
  • This was true prior to ActionBarSherlock 4.0, see stackoverflow.com/a/11794959/952135
    – Oliv
    Nov 20, 2012 at 13:41
6

For version 4.0+, you can simply use the "background" item name.

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="background">@drawable/actionbar_background</item>
</style>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.