Mehmet Mehmet - 3 months ago 22
Android Question

Styling Android Spinner

Is it possible to style an Android Spinner as in the image below with border and an arrow in it?


Answer

I found a solution what I want to do as below.

<Spinner
android:id="@+id/genderBox"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/my_spinner"
/>

and make a xml file in drawable folder and paste following code

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="@android:color/white" />

<stroke
android:width="1dp"
android:color="#d2d2d2" />

<padding
android:bottom="0dp"
android:left="0dp"
android:right="10dp"
android:top="0dp" />
</shape>
</item>
<item>
<bitmap
android:gravity="end"
android:src="@drawable/dropdown_arrow" />
</item>
</layer-list>
Comments