Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify the Size of an Android Spinner Drop down part Size?

how can i modify the size of the dropdown part of the spinner?? do i have to do that in XML or in the code itself?

like image 955
user1297720 Avatar asked Mar 29 '12 10:03

user1297720


2 Answers

In xml, I believe you set it with android:dropDownWidth. This worked for me:

<Spinner
    android:id="@+id/spinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:dropDownWidth="dp_value_you_desire" />
like image 145
Barney Avatar answered Nov 07 '22 07:11

Barney


You can not change the size of spinner as it is default widget. But you can make it custom using background image. Here is my code:

<Spinner 
    android:id="@+id/spinner"
    android:layout_width="fill_parent" 
    android:layout_height="45dp"
    android:drawSelectorOnTop = "true"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="5dp"
    android:layout_marginRight="20dp"
    android:layout_below="@+id/placeCity"
    android:paddingLeft="5dip"
    android:background="@drawable/myspinner_background"
/>
 <ImageView
       android:id="@+id/imageView1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignRight="@+id/spinner"
       android:layout_alignTop="@+id/spinner"
       android:layout_marginRight="5dp"
        android:layout_marginTop="10dp"
       android:src="@drawable/down" />

This is written in XML. And make another file called myspinner_background.xml in drawable folder. Inside that, write this code:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
    android:color="#f269be"
    android:width="2dp" />
<solid
    android:color="#ECC8EC" />

like image 34
Krishna Suthar Avatar answered Nov 07 '22 08:11

Krishna Suthar