ActionBar text color ActionBar text color android android

ActionBar text color


Ok, I've found a better way. I'm now able to only change the color of the title. You can also tweak the subtitle.

Here is my styles.xml:

<?xml version="1.0" encoding="utf-8"?><resources>  <style name="MyTheme" parent="@android:style/Theme.Holo.Light">    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>  </style>  <style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>  </style>  <style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">    <item name="android:textColor">@color/red</item>  </style></resources>


I found a way that works well with any flavor of ActionBar (Sherlock, Compat, and Native):

Just use html to set the title, and specify the text color. For example, to set the ActionBar text color to red, simply do this:

getActionBar()/* or getSupportActionBar() */.setTitle(Html.fromHtml("<font color=\"red\">" + getString(R.string.app_name) + "</font>"));

You can also use the red hex code #FF0000 instead of the word red. If you are having trouble with this, see Android Html.fromHtml(String) doesn't work for <font color='#'>text</font>.


Additionally, if you want to use a color resource, this code can be used to get the correct HEX String, and removing the alpha if needed (the font tag does not support alpha):

int orange = getResources().getColor(R.color.orange);String htmlColor = String.format(Locale.US, "#%06X", (0xFFFFFF & Color.argb(0, Color.red(orange), Color.green(orange), Color.blue(orange))));


I was having the same problem as you, it's a Holo.Light theme but I wanted to style the ActionBar color, so I needed to change the text color as well and also both Title and Menus. So at the end I went to git hub and looked at source code until I find the damn correct style:

<?xml version="1.0" encoding="utf-8"?><!-- For honeycomb and up --><resources>    <style name="myTheme" parent="@android:style/Theme.Holo.Light">        <item name="android:actionBarStyle">@style/myTheme.ActionBar</item>        <item name="android:actionMenuTextColor">@color/actionBarText</item>    </style>    <style name="myTheme.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">        <item name="android:background">@drawable/actionbarbground</item>        <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>    </style>    <style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">        <item name="android:textColor">@color/actionBarText</item>    </style></resources>

so now all you have to do is set whatever @color/actionBarText and@drawable/actionbarbground you want!