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