Mehmet
Mehmet

Reputation: 1560

Styling Android Spinner

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

Upvotes: 0

Views: 1264

Answers (2)

Mehmet
Mehmet

Reputation: 1560

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>

Upvotes: 2

Rathan Kumar
Rathan Kumar

Reputation: 2577

you can use nine patch images. to customize spinner like below

check sample

Upvotes: 3

Related Questions