Question

I'm searching a solution to change textColor of the Option menu items of the HoneyComb's actionBar when items have :

android:showAsAction="ifRoom|withText"

I try a lot of different solutions but none works on my project ... Can someone help me?

Here's what I put in the file style.xml

<resources>
    <style name="theme.app" parent="android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>

    <style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:titleTextStyle">@style/ActionBarTitle</item>
        <item name="android:subtitleTextStyle">@style/ActionBarSubTitle</item>
        <item name="android:background">@drawable/action_bar_background</item>
        <item name="android:paddingLeft">10dp</item>
        <item name="android:actionMenuTextColor">#fff</item>
    </style>

    <style name="ActionBarTitle" parent="@style/ActionBar">
        <item name="android:textColor">@color/blanc</item>
        <item name="android:shadowDx">0</item>
        <item name="android:shadowDy">0</item>
    </style>

    <style name="ActionBarSubTitle" parent="@style/ActionBar">
        <item name="android:textColor">@color/blanc</item>
    </style>
</resources>

P.S. : Sorry if there are any spelling mistakes but I'm a french.

Was it helpful?

Solution

I think you just have android:actionMenuTextColor in the wrong place. It's an attribute on the theme, not the action bar style:

<resources>
    <style name="MyTheme" parent="android:style/Theme.Holo.Light">
        ...
        <item name="android:actionMenuTextColor">#f00</item>
        ...
    </style>
</resources>

A few other things:

  • You can learn a lot about where styles/attributes belong by looking in <sdk>/platforms/android-13/data/res/values/, specifically at attrs.xml, themes.xml, and styles.xml.
  • You can also use android:actionMenuTextAppearance to provide a text appearance (a collection of size/style/color/etc. information) all at once.
  • It doesn't make sense for your ActionBarTitle style to have @style/ActionBar as a parent style.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top