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

ε祈祈猫儿з 提交于 2019-12-24 10:34:33

问题


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?


回答1:


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>



回答2:


//there is no abBackground

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

//try

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



回答3:


if the project is a library module you shou check the Library module



来源:https://stackoverflow.com/questions/11794809/error-no-resource-found-that-matches-the-given-name-attr-abbackground

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!