I'm working through the Android Build Your First App tutorials, and I've got to Styling The Action Bar.
I created this themes.xml file as per the tutorial:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
</style>
My problem is, that I don't know how to define actionbar_background.
Of course, I get the following error:
Error:(12, 41) No resource found that matches the given name (at 'android:background' with value '@drawable/actionbar_background').
I guessed that it is a colour, but how do I define it?
just as a quick "first build" thing you can change to a color code, like this:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#aaaaaa</item>
</style>
but in you can make it to be any color or drawable.
Colors are usually defined in a separate file like this:
colors.xml
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<color name="disabled_text">#9FFF</color>
<color name="actionbar">#000</color>
<color name="background">#111</color>
... etc
</resources>
and drawables are defined as .png files placed in your drawables-... folders, or define as XML files in the drawables folder.
then referenced on the styles like this:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/disabled_text</item>
</style>
or for a actionbar_background.png in the drawables-... folders
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
</style>
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