Search code examples
androidactionbarsherlock

Error: No resource found that matches the given name: attr 'abBackground'


I'm using ActionBarSherlock, and want to use a custom background for both the ActionBar and the content view below it. When I try this, the background fills the whole screen, including the actionbar:

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="android:windowBackground">@drawable/background</item>
</style>

So, from this answer, I tried to add abBackground to the theme:

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="android:windowBackground">@drawable/background</item>
    <item name="abBackground">@drawable/bg_button_idle</item>
</style>

However, I get the error

Error: No resource found that matches the given name: attr 'abBackground'.

Why is this, and how can I fix it?


Solution

  • Here's how you can change the actionbar background:

    <style name="MyTheme" parent="Theme.Sherlock">
        <item name="actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>
    
    <style name="MyActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="background">@drawable/your_custom_drawable</item>
        <item name="android:background">@drawable/your_custom_drawable</item>
    </style>