1 year ago
#345712
anta40
How to customize the color of Android spinner's dropdown arrow?
I have a Spinner which background is white
The problem is there's no dropdown arrow, so users wouldn't easily recognize that this field is a spinner/dropdown.
Here's my code:
MainActivity.java
String[] arrPaymentTypes = {"Cash", "Bank Transfer", "Wallet"};
ArrayAdapter<String> spnPaymentTypeAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, arrPaymentTypes);
spnPaymentTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnPaymentType.setAdapter(spnPaymentTypeAdapter);
spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:gravity="left"
android:textColor="@color/black"
android:padding="1dip"
/>
activity_main.xml
<Spinner
android:id="@+id/spnPaymentType"
style="@style/mySpinnerItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lblPaymentType
android:popupBackground="@color/white" />
/values/styles.xml
<style name="mySpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textColor">@android:color/white</item>
</style>
I tried adjusting a few Spinner proprties like backgroundTint
and doesn't work. What's the proper solution?
android
android-spinner
0 Answers
Your Answer