2

I'm trying to customize the arrow image in a spinner. Here's my code:

LayoutInflater inflater = LayoutInflater.from(context);
spin = (Spinner) inflater.inflate(R.layout.spinner, null);
adapter = new ArrayAdapter<Choice>(context, R.layout.nitro_spinner_item, choicesArr);
adapter.setDropDownViewResource(R.layout.multiline_spinner_dropdown_item);
spin.setAdapter(adapter);

and R.layout.nitro_spinner_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@android:id/text1"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:drawableEnd="@drawable/ic_action_acf"
      android:ellipsize="marquee"
      android:singleLine="true"
      android:textAlignment="inherit"/>

But here's what I get: enter image description here

I see my custom image, along with the normal Android dropdown arrow. I used the answer here as reference: https://stackoverflow.com/a/30336734/1642002 . Where does the stock dropdown image come from if I've overridden the text view?

Community
  • 1
  • 1
regretoverflow
  • 2,093
  • 1
  • 23
  • 45

1 Answers1

1

Just set the background of the Spinner widget to transparent:

<Spinner
        android:id="@+id/spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"/>
Lolo06
  • 99
  • 1
  • 5