Here is what you have to do to make it work :
1 - Define your style in a file, for example : "values/myStyle.xml" :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <resources> <style name="Theme.MyActionBarTheme" parent="@style/Theme.AppCompat.Light"> <!-- This is for Support library compatibility --> <item name="actionBarStyle">@style/MyActionBarStyle</item> <item name="android:actionBarStyle">@style/MyActionBarStyle</item> </style> <!-- general styles for the action bar --> <style name="MyActionBarStyle" parent="@style/Widget.AppCompat.ActionBar"> <!-- This is for Support library compatibility --> <item name="titleTextStyle">@style/MyActionBarTextStyle</item> <!-- Define your background color in colors.xml --> <item name="background">@color/action_bar_background</item> <item name="android:titleTextStyle">@style/MyActionBarTextStyle</item> <item name="android:background">@color/action_bar_background</item> </style> <!-- Define your actionBar title text Style : Here I defined only the textColor property --> <style name="MyActionBarTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">#ff55cc</item> </style> </resources> |
2 - Apply your style to your application in your "AndroidManifest.xml" file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <application android:name=".YourApplicationName" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.MyActionBarTheme"> <activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> |
That's it, easy peasy :)
0 comments:
Post a Comment
Leave your Comment