3

I have set a dropdown icon for the spinner.I have used a custom layout for the spinner items.When it is run the drop down icon does not appear. activity_main.xml:

<Spinner
    android:id="@+id/spinner1"
    android:layout_width="200dp"
    android:layout_height="70dp"
    android:gravity="center"
    style="@android:style/Widget.Spinner.DropDown"
    android:background="@drawable/drop_down_style"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"/>

drop_down_style.xml:

<?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/transparent" />
            <padding
                android:bottom="10dp"
                android:left="2dp"
                android:right="10dp"
                android:top="10dp" />
        </shape>
    </item>
    <item>
        <bitmap
            android:gravity="end"
            android:src="@drawable/drop" />
    </item>
</layer-list>

spinner_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="50dp"
    android:background="@drawable/spinner_style" >

    <TextView
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Aizwal"
        android:padding="4dp"
        android:textColor="#212121"
        android:textSize="25sp" />
</FrameLayout>
Vladimir Markeev
  • 654
  • 10
  • 25
jobin
  • 1,489
  • 5
  • 27
  • 52
  • Possible duplicate of [How to set dropdown arrow in spinner?](http://stackoverflow.com/questions/20422802/how-to-set-dropdown-arrow-in-spinner) – Bharatesh Mar 14 '16 at 05:38

2 Answers2

4

Remove this line from

android:background="@drawable/drop_down_style"

Reason: background overlaps the drop down arrow.

0

Change

 style="@android:style/Widget.Spinner.DropDown"

into

  style="@android:style/Widget.Spinner"

and see if it works and let me know. If it doesn't will investigate further.

Ragesh Ramesh
  • 3,470
  • 2
  • 14
  • 20