android - Spinner arrow disappears when I change the background color


Keywords:android 


Question: 

When I change the background color of my spinner, the drop-down arrow disappears. I have seen some answers to similar questions here, but they don't really address how to make the arrow "reappear" or change the arrow's color directly from the XML (assuming that's possible).

I am trying to make the arrow white, but the spinner (using the code below) still appears without the arrow.

<Spinner
    android:id="@+id/eventSpinner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:background="@android:color/holo_green_dark"
    android:dropDownSelector="#ffffff"
    android:popupBackground="@android:color/holo_green_dark"
    android:spinnerMode="dropdown" />

Any help would be appreciated. Thanks in advance.


1 Answer: 

You can draw line by xml code. like below

    <item >

    <layer-list>

        <item>
            <shape android:shape="rectangle" >
                <solid android:color="@android:color/transparent" />
                <!-- background color of box -->
            </shape>
        </item>
        <item
            android:left="-2dp"
            android:right="-2dp"
            android:top="-2dp">
            <shape>
                <solid android:color="@android:color/transparent" />

                <stroke
                    android:width="1dp"
                    android:color="#323232" />
                <!-- color of stroke -->
            </shape>
        </item>

        <item android:right="5dp">
            <bitmap android:gravity="center_vertical|right" android:src="" />

        </item>

    </layer-list>

   </item>

output looks something like this enter image description here