Reputation: 11
I have a contextual action mode, the text color of the action bar menu should be red in color. I am able to change the text color using
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:actionBarStyle">@style/MyStyledActionBar</item>
</style>
<style name="MyStyledActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:background">@drawable/bg_action_bar</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:actionMenuTextAppearance">@style/MyActionBarMenuText</item>
<item name="android:actionMenuTextColor">@style/MyActionBarMenuText</item>
<item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverFlow</item>
</style>
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionBarMenuText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionButtonOverFlow" parent="@style/Widget.AppCompat.Light.Base.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_search</item>
</style>
It works in android 2.3, 4.1. but when i run the same in android 4.4. It shows the default black color
Can anyone please let me know, what is the issue.
Thanks in advance.
Upvotes: 1
Views: 2643
Reputation: 1073
Maybe it is not the cleanest way to do this but to change the color of my action bar text I use HTML code in the java classe like this:
getSupportActionBar().setTitle(Html.fromHtml("<font color='#FF0000'>"+Your Title+"</font>"));
Hope it helps!
Upvotes: 1
Reputation: 3122
please use below code its working for me
and still if you have doubt and its not working then tell me
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppTheme" parent="AppBaseTheme">
<!-- <item name="windowBackground">@color/background_window</item> -->
<!-- <item name="android:actionBarStyle">@style/ActionBarStyle</item> -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.ActionBar">
<item name="android:icon">@drawable/ic_launcher</item>
<item name="android:background">#FF666666</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/holo_blue_bright</item>
</style>
Upvotes: 0