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

时间:2012-08-03 11:27:24

标签: android actionbarsherlock

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

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

所以,从this answer开始,我尝试将abBackground添加到主题中:

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

然而,我收到错误

  

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

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

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

//没有abBackground

 <item name="abBackground">@drawable/bg_button_idle</item>

//尝试

<item name="android:background">@drawable/bg_button_idle</item>

答案 2 :(得分:-2)

如果项目是库模块,则应检查库模块enter image description here