Reputation: 2801
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
Upvotes: 2
Views: 8406
Reputation: 1
You are missing a reference file in drawable folder. you will find the folder under res just put an image file under drawable named as actionbar_background and the error should be resolved. you can download the image just google actionbar_background. hope it helps
Upvotes: -1
Reputation: 16526
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
Upvotes: 12
Reputation: 7066
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));
Upvotes: 5