Text color of a closed spinner

To modify the text color create a new xml file in your res/layout folder (for example my_spinner_text.xml). Add a text view to the new xml file and modify how you want:

<TextView android:id="@+id/spinnerText" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true"
    android:textColor="#CCCCCC" 
    android:textSize="20dp" 
    xmlns:android="http://schemas.android.com/apk/res/android"/>

Create an ArrayAdapter that uses the new TextView and set it to your spinner:

    Spinner localSpinner = (Spinner)findViewById(R.id.mySpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.spinner_array,
                R.layout.my_spinner_text);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    localSpinner.setAdapter(adapter);

Leave a Comment