0

trying to change actionbar text color of this item in the action bar. here is the item

<item android:id="@+id/options_button"
        android:title="@string/options"
        android:showAsAction="ifRoom|withText"/>

and here is my styles.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBarTheme</item>
        <item name="android:background">@color/White</item>
        <item name="android:textColor">@color/Red</item>
    </style>

    <style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/White</item>
        <item name="android:textColor">@color/Red</item>
    </style>
</resources>

i saw other posts on here about this but after trying their solutions nothing worked for me? is it something to do with how i made the theme? All i really wanted was my action bar to be white, not display the title, and display a button that says options. I have all of that, but the options I want to be a red color im working with rather than black.

dont think people understand...

I know of the way to change the title (I dont have a title and i dont want one).I want to change the color of the item that is displaying itself in the actionbar...

erp
  • 2,950
  • 9
  • 45
  • 90

1 Answers1

1

I have faced the same issue, but I found a solution that doing well with any type of ActionBar (Native, Sherlock or Compat)

Actually you can use HTML code 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 hex code of red color #FF0000 instead of the word red.

But, Setting a HTML string on the action bar doesn't work on the Material theme in SDK v21+.

If you want to change it you should set the primary text color in your style.xml as below.

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Material.Light">
        <!-- Customize your theme here. -->
        <item name="android:textColorPrimary">@color/actionbar-text-color</item>

May this helps you.