1. Set the background color of the action bar
The first way: Getactionbar (). Setbackgrounddrawable (Getresources (). getdrawable (R.drawable.actionbarbackground));
Actionbarbackground for the definition in Values/colors.xml
Colors.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<drawable name= "Actionbarbackground" > #ED4026 </drawable>
</resources>
This method features: simple and convenient, but must be set in the code, if the different activity common with the same actionbar style, it is not conducive to reuse. So, refer to the second way
The second way: given by an official document, by setting the properties of the theme. (different activity can be reused)
Specific practices: (The following method is suitable for 3.0 and above, 2.1 and above reference official documents)
Res/values/themes.xml
<?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>
</RESOURCES>
Then apply Your theme to your entire app or individual activities:
span>
<application android:theme< Span class= "pun" >= "@style/customactionbartheme" ... />
Modify <style name= "Appbasetheme" parent= "@android: Style/theme.holo" >&NBSP;
or add the above file contents to Styles.xml
Actionbar_background can be added to the Colors.xml file
Reference: http://blog.csdn.net/jwzhangjie/article/details/28852967
Reference: http://blog.csdn.net/yueqinglkong/article/details/20876401
Android Actionbar Custom