Reputation: 906
I am trying to modify the text color of the title of the ActionBarSupport. I have used ActionBarStyleGenererator to create a theme with the correct colors and it works well.
While using the light theme, I would like to change the color of the heading to white (in the genererator I cannot set the text color(. For a number of reasons I cannot use the dark actionbar theme. I am so close, just have to get the title to white ;-)
What I am doing wrong here?
<style name="ActionBar.Transparent.MyApp" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@drawable/ab_transparent_myapp</item>
<item name="progressBarStyle">@style/ProgressBar.MyApp</item>
<item name="titleTextStyle">@style/MyApp.TitleTextStyle</item>
</style>
<style name="MyApp.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
Upvotes: 6
Views: 9835
Reputation: 8138
@TNR is correct, however you should double check if your layout xml file has not overriden the android:theme
attribute with a different style.
This usually happens if you have generated layout files
Upvotes: 0
Reputation: 159
Found at Overflow styling
I've been trying to keep the ActionBar title text color through orientation changes without much luck until I got a clue from the above site. I applied the Spannable to to the title. Here's what i do when setting up my ActionBar:
Spannable actionBarTitle = new SpannableString("Action Bar Title");
actionBarTitle.setSpan(
new ForegroundColorSpan(Color.WHITE),
0,
actionBarTitle.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mActionBar.setTitle(actionBarTitle);
This needs to be executed on orientation change. I call it from onCreate()...don't know if it works in onConfigurationChange().
Upvotes: 3
Reputation: 906
Embarrassing. I was not paying attention to the values-v14/-folder (which overrides the vales/) ActionBarStyleGenererator created. Using the android-prefix on the styles in values-v14 it worked:
<item name="android:titleTextStyle">@style/titleTextStyle</item>
Upvotes: 5
Reputation: 5869
The below code worked for me. I hope it will help you tooo.
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">@style/ActionBarCompat</item>
</style>
<style name="ActionBarCompat" parent="@style/Widget.AppCompat.Base.ActionBar">
<item name="titleTextStyle">@style/titleStyle</item>
</style>
<style name="titleStyle" parent="@style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
</style>
Upvotes: 14