Paul
Paul

Reputation: 36319

Actionbarsherlock background image

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

Upvotes: 0

Views: 7589

Answers (2)

Robert Greathouse
Robert Greathouse

Reputation: 1034

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>

Upvotes: 6

Kavi
Kavi

Reputation: 3880

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

Upvotes: 12

Related Questions