change Spinner text color

19,108

Try like this only for selected item color change:

spinnerObject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
    ((TextView)parentView.getChildAt(0)).setTextColor(Color.RED);
}
});

Another way:

<style name="spinnerTheme">
<item name="android:textColor">@color/gray_dark</item>
</style>

<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:theme="@style/spinnerTheme"/>
Share:
19,108
musigh
Author by

musigh

love logics of life

Updated on June 04, 2022

Comments

  • musigh
    musigh almost 2 years

    I want to change the default text color in Spinner to any other color. But I have not find the solution yet. All I got a solution through TextView like How to change spinner text size and text color?
    Is there any other way, direct way for Spinner?

    Note: Please provide solution for Xamarin. Thank you.

  • musigh
    musigh over 5 years
    help me with Xamarin, Thanks.
  • musigh
    musigh over 5 years
    help me with Xamarin. Thanks
  • musigh
    musigh over 5 years
    Thanks, It works in pop up window text color but now the only problem left, is the default text color in spinner, which is black. how to change that?
  • Mani Vasagam
    Mani Vasagam over 5 years
    write custom style to change the text color