错误:找不到与给定名称匹配的资源:attr'abBackground'

nha*_*man 1 android actionbarsherlock

我正在使用ActionBarSherlock,并希望为ActionBar和它下面的内容视图使用自定义背景.当我尝试这个时,背景填满整个屏幕,包括操作栏:

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="android:windowBackground">@drawable/background</item>
</style>
Run Code Online (Sandbox Code Playgroud)

所以,从这个答案,我试图添加abBackground到主题:

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="android:windowBackground">@drawable/background</item>
    <item name="abBackground">@drawable/bg_button_idle</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但是,我得到了错误

错误:找不到与给定名称匹配的资源:attr'abBackground'.

为什么会这样,我该如何解决?

Ben*_*oli 8

以下是您可以更改操作栏背景的方法:

<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>
Run Code Online (Sandbox Code Playgroud)

  • 你需要一个动作栏样式的`android:background项目以及ICS +. (2认同)