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

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?

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>

//there is no abBackground
<item name="abBackground">#drawable/bg_button_idle</item>
//try
<item name="android:background">#drawable/bg_button_idle</item>

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

Related

AIDE doesn't recognise colorPrimary

Using AIDE on phone to create apps...
Dont know why but AIDE doesn't recognise the colorPrimary & colorPrimaryDark...
throws error like 'No Resource Found'
I am currently able to change the ActionBar color by this Code -
`
<style name="MyCustomTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#075E54</item>
</style>
`
How do I change the StatusBar color?
Add the colorPrimary, colorPrimaryDark and colorAccent to MyActionBarTheme
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="colorPrimary">#color/DarkBlue</item>
<item name="colorPrimaryDark">#01517f</item>
<item name="colorAccent">#color/Gray2</item>
</style>
replace the values for colors to what you want.

Style showing error in android

The following style shows error in eclipse
<style name="AppTheme" parent="android:style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="colorControlNormal">#color/primary</item>
<item name="colorControlActivated">#color/primary</item>
<item name="colorControlHighlight">#color/primary</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/white</item>
</style>
it shows a error like this
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.AppCompat.Light.NoActionBar'.
while i searched, i get to know that it is the problem of the dependency. I tried a lot to solve it. But i still get the same error .
If i change the theme there is no error, but i need this particular style.
I tried the following theme
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
// Your style here
this is woking . but i need the above theme .
If your activity extends AppCompactActivity, your parent theme should be
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.NoActionBar" />
where as, if using ActionBarActivity, theme should be
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar" />
Make sure you have set up the dependencies in your project. This feature required appcompactv7.

Overriding ActionBarCompat overflow pop-up background?

I am using actionbarcompat for my android project and using #style/Theme.AppCompat.Light.DarkActionBar as my base Theme.The overflow menu in this action bar has a black background by default which I want to change to white color.I know this can be done overdding the popup widget with property popupBackground but its not working in my case.My styles file has following code:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionDropDownStyle">#style/MyActionBarDropDown</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
But the above code is not running as its giving me Error: No resource found that matches the given name: attr 'popupBackground'.SomeOne please help me to correct above code.
Just remove ->
<item name="popupBackground">#drawable/menu_dropdown_panel_example</item>
Put it like this ->
<style name="PopupMenu" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>

Setting styles in Android

Hey guys I am new to development for the Android, I have a question for a project I am working on:
Using these styles to style my actionbar:
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
</style>
</resources>
I get an error for both styles, they say:
error: Error retrieving parent for item: No resource found that matches the given name '#style/
Theme.Holo.Light.DarkActionBar'.
error: Error retrieving parent for item: No resource found that matches the given name '#style/
Widget.Holo.Light.ActionBar.Solid.Inverse'.
I am putting these in a separate XML file called themes. In my style XML file I have the theme android:Theme.Light
If you could give me a suggestion or whatnot as to what is wrong here I would appreciate it!
David
"#style/Theme.Holo.Light.DarkActionBar"
You are referring to the styles in your values/styles.xml and you do not have the style mentioned in styles.xml. You probable meant to refer to the one in the android style package like #android:style/..
Change to
<resources>
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
</style>
</resources>

can't change color of actionBar divider

I tried change color of my actionBar divider , but nothing work. I' using android support library v7 for support old devices and custom style, and i also change all action bar drawable, but nothing happend!
<resources>
<style name="MyTheme" parent="Theme.AppCompat">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent = "Widget.AppCompat.ActionBar">
<item name="background">#drawable/my_action_bar</item>
</style>
</resources>
And my ide show me strange error in layout , why did i get this error? it's not color value
java.lang.NumberFormatException: Color value '#drawable/abs__ab_transparent_dark_holo' must start with #
Solution: Need to add android namespace if use for api level >= 14 .May be it will be helpful to someone.
It is because the "divider" is an image. It's hardcoded in the Holo theme assets.
Look at platforms/android-19/data/res/drawable-xxhdpi/ab_transparent_dark_holo.9.png
The style is declared here for holo dark.
<style name="Widget.Holo.ActionBar" parent="Widget.ActionBar">
...
<item name="android:background">#android:drawable/ab_transparent_dark_holo</item>
...
</style>
It's a background. You will need to change the color in the image and replace the background of your bar.
It also needs different sizes for different resolutions.
Maybe you should set color directly, change your theme as
<item name="android:divider">#color/dividercolor</item>
Then you should add color dividercolor in you /value/color file,like
<item name="dividercolor"> #0099CC </item>
I hope this will be helpful to you
<style name="CustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
<item name="android:actionBarDivider">#drawable/action_vertical_doted</item>
<item name="android:actionButtonStyle">#style/MyTheme.ActionBar.ActionButton</item>
<item name="android:actionMenuTextColor">#ffffff</item>
<!-- <item name="android:actionMenuTextAppearance">#style/MyTheme.Menu.FontStyle</item> -->
<!-- <item name="android:actionBarSize">50dp</item> -->
</style>
<style name="MyTheme.ActionBarStyle" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#drawable/actionbar_bg_shap</item>
<item name="android:displayOptions">none</item>
<item name="android:backgroundSplit">#drawable/actionbar_bg_shap</item>
</style>
<style name="MyTheme.ActionBar.ActionButton" parent="#android:style/Widget.Holo.Light.ActionButton">
<item name="android:background">#drawable/main_button_inactive_tr</item>
</style>

Categories

Resources