Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Actionbar navigation spinner text color

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?

like image 238
Anthea Avatar asked Sep 12 '12 19:09

Anthea


1 Answers

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!

like image 104
giorgiline Avatar answered Oct 26 '22 22:10

giorgiline