开发者

Android: Spinner background with a drop down shape

Currently I am using this xml for the background of my spinner:

<item android:state_pressed="true" >
    <shape>
        <gradient
            android:startColor="#008000"
            android:endCol开发者_开发知识库or="#7FFF00"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="#A8A8A8" />
        <corners
            android:radius="6dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

<item>        
    <shape>
        <gradient
            android:endColor="#ffc536"
            android:startColor="#ffe9b3"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="#e4962d" />
        <corners
            android:radius="6dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

And I like the color and the gradient however there is no indicator that there it is a drop down menu. Is there anyway to add a image or a shape to the right side to indicate a drop down menu? I found this easier then make 9-patch files.


You need to create a custom component and write an XML file and a UI element for it to implement this.

Simply treat the UI element as a drop-in version of what you're trying to implement.

Hope this helps!


i know that this question is old but i resolve in this way :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
        <solid android:color="#FFFFFF" />
        <stroke
            android:width="1dp"
            android:color="@color/green" />
        <corners android:radius="3dp" />
    </shape>
</item>
<item>
    <bitmap
        android:gravity="right|center"
        android:src="@drawable/ic_arrow_drop_down" />
</item>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜