Alex Curran
Alex Curran

Reputation: 8828

Theming with ActionBarSherlock not working

I can't seem to get the theming of the action buttons working either using ABS or the standard ActionBar. Despite using selectableItemBackground in my theme, it still uses the blue highlight instead of the requested red one. However, it seems to work fine for the discard button in the SearchView (see attached images).

I'm sure I'm missing something simple, anyone know what?!

Pressed Action Buttons use this highlight: Showing the wrong highlight

When they should be using this one: Showing the right highlight

This is the style I'm using:

<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="actionBarTabStyle">@style/MyActionBarTabStyle</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
    <item name="android:fastScrollThumbDrawable">@drawable/fastscroll</item>
    <item name="android:editTextStyle">@style/Widget.Styled.EditText</item>
    <item name="android:selectableItemBackground">@drawable/selectable_background</item>
</style>

UPDATE

using <item name="android:actionBarItemBackground">@drawable/selectable_background</item> seems to work, but this isn't what Nick Butcher's article on theming uses. Is this acceptable/will it break anything?

Upvotes: 1

Views: 2108

Answers (1)

Jake Wharton
Jake Wharton

Reputation: 76075

That article was written for Android 3.0 and the attribute changed for Android 4.0 which is why you are seeing the difference in behavior.

Using actionBarItemBackground is now the correct method of changing the background of action items.

If you're using ActionBarSherlock remember that you need both android-prefixed and non-prefixed version in the theme for it to work on all API levels.

Upvotes: 6

Related Questions