Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 354
Christopher Perry Avatar asked May 28 '11 01:05

Christopher Perry


People also ask

How do I hide spinner text?

You can hide spinner in the ProgressButton by setting the e-hide-spinner property to cssClass . Is this page helpful?

What is a spinner view in Android?

Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one. You can add a spinner to your layout with the Spinner object.

How do I add a spinner to my toolbar?

Adding spinner to app bar/ toolbar is very simple, you just need to create a XML file in res/menu/ folder and add a item like your over flow menu and spinner widget as item actionViewClass, rest in your java code. Spinner can be added to android actionbar/toolbar with many ways.

What is custom spinner in Android?

In Android, Spinners provides you a quick way to select one value from a set of values. Android spinners are nothing but the drop-downlist seen in other programming languages. In a default state, a spinner shows its currently selected value. It provides a easy way to select a value from a list of values.


1 Answers

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> <style name="Widget.DropDownItem.Spinner">     <item name="android:checkMark">?android:attr/listChoiceIndicatorSingle</item> </style> 

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

and here's how it's done:

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="MooTheme" parent="android:Theme">         <item name="android:spinnerItemStyle">@style/MooSpinnerItem</item>     </style>      <style name="MooSpinnerItem" parent="android:Widget.TextView.SpinnerItem">         <item name="android:textAppearance">@style/MooTextAppearanceSpinnerItem</item>     </style>      <style name="MooTextAppearanceSpinnerItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">         <item name="android:textColor">#F00</item>     </style> </resources> 

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

android:theme="@style/MooTheme" 
like image 60
CaseyB Avatar answered Oct 15 '22 23:10

CaseyB