Christopher Perry Christopher Perry - 1 year ago 61
Android Question

Android: Where is the Spinner widget's text color attribute hiding?

I'm trying to change the text color of the single item that is displayed in the spinner button after you select an item from the dropdown. I've been perusing the themes.xml and styles.xml in the Android SDK for an hour now, and I can't seem to find where the Spinner is getting the color value from.

To clarify, I'm NOT trying to change the color of a dropdown item, I'm trying to change the color of the spinner's displayed text when there is no dropdown. I guess you could call it the spinner's 'button' text.

Answer Source

I think it's probably this bit in styles.xml

<style name="Widget.TextView.SpinnerItem">
    <item name="android:textAppearance">@style/TextAppearance.Widget.TextView.SpinnerItem</item>
<style name="Widget.DropDownItem.Spinner">
    <item name="android:checkMark">?android:attr/listChoiceIndicatorSingle</item>

-= EDIT =- Here's the result: enter image description here

and here's how it's done:

<?xml version="1.0" encoding="utf-8"?>
    <style name="MooTheme" parent="android:Theme">
        <item name="android:spinnerItemStyle">@style/MooSpinnerItem</item>

    <style name="MooSpinnerItem" parent="android:Widget.TextView.SpinnerItem">
        <item name="android:textAppearance">@style/MooTextAppearanceSpinnerItem</item>

    <style name="MooTextAppearanceSpinnerItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
        <item name="android:textColor">#F00</item>

Then just add this to the application tag in your AndroidManifest.xml

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download