Here is a simple way how to change the background and text color on the Android AppCompat Light DarkActionBar.
Here is the final result:
Let say your app has following name :<MyTheme>
and you are using the Andoird 3.0 version.
In res/AndoidManifest.xml you will have following code:
1 2 3 |
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" /> |
1. Add following code in the res/values/styles.xml file:
1 2 3 4 5 6 7 8 9 10 11 12 |
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid"> <item name="titleTextStyle">@style/MyTitleTextStyle</item> <item name="background">@color/actionBarBg</item> </style> <style name="MyTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">@color/actionBarText</item> </style> |
2. Create the color definition file under: res/values/colors.xml and add following code:
1 2 3 4 5 6 7 8 |
<resources> <!-- White text color --> <color name="actionBarText">#FFFFFF</color> <!-- facebook blue color --> <color name="actionBarBg">#45619D</color> </resources> |
That’s all.
In the next tutorial we will see How to show icons in ActionBar overflow menu