First set the Spinner background to @null to remove the default triangle:
<Spinner android:id="@+id/spinner_main" android:spinnerMode="dropdown" android:background="@null" android:layout_width="wrap_content" android:layout_height="match_parent"/>
Then create a spinner_item_main.xml layout resource only with a TextView, which we can set with the ability to draw on its right side (you can download the arrow image from here ):
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:textStyle="bold" android:gravity="left" android:textColor="@color/colorWhite" android:drawableRight="@drawable/ic_arrow_drop_down_white_24dp" />
Finally Install this layout resource, when you initialize Spinner, you can also provide the resource as a drop-down list (like what I did):
(I use kotlin)
spinner_main.adapter = ArrayAdapter<String>(this, R.layout.spinner_item_main, objects).apply { setDropDownViewResource(R.layout.spinner_dropdown_view_main) }
Do this! View this in My AP app
source share