Hey guys I am newer to Android development and I am working on changing my ActionBar's background. When adding the following in my themes.xml file within res->values
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
</style>
I receive this error message:
error: Error: No resource found that matches the given name (at 'android:background' with value '@drawable/
actionbar_background').
I am not positive why I am receiving this message and could use a hand.
David
Just guessing, but my bet is that you don't have any drawable named actionbar_background.png
Double check for possible typos in your png resource. It should be in any drawable folder. Or you could just set a color with.-
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF0000</item>
</style>
Please notice that hardcoding values is a bad practice. If you finally go for a background color, you should consider creating a resource item for that color, in a separate resource file (i.e. colors.xml)
<color name="red">#FF0000</color>
And reference it with in your item style with @color/red
You can use it when activity created. (onCreate)
ActionBar bar = getActionBar();
//for color
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00C4CD")));
//for image
bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.settings_icon));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With