You need to create a custom layout in order to create a custom Spinner
.
Create a layout file spinner_item.xml
Create your own layout file with a custom definition for the spinner item. This is my spinner_item.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#ff0000" />
Change your declaration of the spinner to use the R.layout.spinner_item
:
// Declare the spinner
Spinner feedbackSpinner = (Spinner) findViewById(R.id.SpinnerFeedbackType);
// Set the custom layout to the array adapter, and send your array feedbacktypelist with the data
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.feedbacktypelist, R.layout.spinner_item);
feedbackSpinner.setAdapter(adapter);
This is the result
Now, to customize the dropdown list items you will need to create a new layout file to the dropdown.
Create a layout file called spinner_dropdown_item.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee"
android:textColor="#aa66cc"/>
Change the declaration of the spinner
// Declare the spinner
Spinner feedbackSpinner = (Spinner) findViewById(R.id.SpinnerFeedbackType);
// Set the custom layout to the array adapter, and send your array feedbacktypelist with the data
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.feedbacktypelist, R.layout.spinner_item);
// Set the custom layout for the drop down items.
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
feedbackSpinner.setAdapter(adapter);
This is the result:
Basically that's it.
Source of the answer. How to change a Spinner text size, color or overall style
Hope this helps you.