background
The UI requires a visual drop-down box as follows:
Solution: Set the background image of Spinner as follows:
<Spinner
android:id="@+id/sp_gender"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_gender"
android:entries="@array/gender" />
shape_gender is the shape drawn by myself:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="4dp" />
<stroke
android:width="1dp"
android:color="#C8C8C8"
/>
</shape>
</item>
<item>
<bitmap
android:gravity="end"
android:src="@drawable/icon_user_info_pull"
/>
</item>
</layer-list>
Here I want to talk about layer-list in particular. Anyone who has studied PhotoShop knows the concept of layers. It is the same here. You can draw one layer at a time. The one written at the bottom will be displayed at the top.
So we can use rounded corners, use pictures to splice and align, etc.