Android Actionbar navigation spinner text color

11,018

I was looking for the same answer but didn't find anything, so I tried this solution. I works for me at least.

In the themes file, you can set the style for the spinnerDropdownItemStyle:

<style name="YourTheme" parent="YourParentTheme">
    <item name="android:spinnerDropDownItemStyle">@style/YourCustomDropDownItemStyle</item>
</style>

Now, set the textappearance for your style:

<style name="YourCustomDropDownItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/YourCustomDropDownItemTextStyle</item>
</style>

And in your custom textappearance you can set the text details:

<style name="YourCustomDropDownItemTextStyle" parent="@android:style/Widget">
    <item name="android:textColor">@color/white</item>
    <!-- Here you can set the color and other text attributes -->
</style>

Hope this helps!

Share:
11,018
Anthea
Author by

Anthea

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher’s Law of Software Engineering)

Updated on June 13, 2022

Comments

  • Anthea
    Anthea almost 2 years

    I am able to change the background of the navigation spinner:

      <style name="MyTheme" parent="android:style/Theme.Light">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
            <item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
        </style>
    
      <style name="MyDropDownNav" parent="android:style/Widget.Spinner">
            <item name="android:background">@drawable/spinner_white</item>
            <item name="android:textColor">@color/red</item>
        </style>
    

    Nevertheless the textColor is not changed. I also tried other ways to change the textColor:

     <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
            <item name="android:background">?color_actionbar</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/violet</item>
        </style>
    

    Any other idea?

  • Mike6679
    Mike6679 about 11 years
    No resource found that matches the given name 'Widget
  • giorgiline
    giorgiline about 11 years
    @Mike If you're using Sherlok Action Bar, use parent="TextAppearance.Sherlock.Widget.ActionBar.Title", if not, it should be something similar.
  • Alex Semeniuk
    Alex Semeniuk about 11 years
    He forgot to add android: in front of the Widget
  • Dr. aNdRO
    Dr. aNdRO over 10 years
    can you please elaborate how to use it? and what about this parent theme?
  • ErenRavenHeart
    ErenRavenHeart over 9 years
    I have this error,.. No resource found that matches the given name (at 'android:textColor' with value '@color/white')..
  • Pink Jazz
    Pink Jazz over 7 years
    The text color is not changing for me.