I need to change the color of the spinner popup. Here is what I have attempted till now: java code:
ArrayAdapter<Integer> adapter_year = new ArrayAdapter<Integer>(this, R.drawable.custom_spinner_holidays, year);
adapter_year.setDropDownViewResource(R.layout.customize_spinner);
custom_spinner_holidays.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@drawable/custom_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@android:color/white" />
customize_spinner.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/spinnertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0193DE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
But it doesn't work. I get error when I click on the spinner.
You are making things complicated! Just add this to your main spinner xml
android:popupBackground="#yourcolor"
and change your java code as:
adapter_year.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With