2012-08-03 85 views
1

我正在使用ActionBarSherlock,并且希望为其下方的ActionBar和内容视图使用自定义背景。当我尝试这一点,背景填充整个屏幕,其中包括动作条:错误:找不到与给定名称匹配的资源:attr'abBackground'

<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> 

但是,我得到的错误

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

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

回答

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> 
+2

您还需要一个操作栏风格的'android:background'项目以及ICS +。 – 2012-08-03 17:12:45

0

//没有abBackground

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

//尝试

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

在整个布局中使用背景f *,所以这不是一个选项。 – nhaarman 2012-08-03 11:42:32

+0

如果您使用贝尼托回答它不。 – Laranjeiro 2013-04-02 15:49:42

-2

如果该项目是一个库模块你应该检查库模块enter image description here

+0

不知道你试图在这里说什么,这肯定不是一个问题 – 2016-01-05 08:58:15

+0

的问题的答案对不起,我通过它是你的主要模块无法找到你的库模块src。 – 2016-05-10 15:15:07

相关问题