How to create custom spinner like border around the spinner with down triangle on the right side?

前端 未结 7 2029
死守一世寂寞
死守一世寂寞 2020-11-30 18:33

I want to develop custom spinner like line around spinner with triangle at right bottom corner.
like following image

相关标签:
7条回答
  • 2020-11-30 19:20

    This is a simple one.

    your_layout.xml

    <android.support.v7.widget.AppCompatSpinner
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/spinner_background"
    />
    

    In the drawable folder, spinner_background.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item><layer-list>
        <item>
            <shape>
                <solid
                    android:color="@color/colorWhite">
                </solid>
    
                <corners android:radius="3dp" />
    
                <padding
                    android:bottom="10dp"
                    android:left="10dp"
                    android:right="10dp"
                    android:top="10dp" />
                <stroke
                    android:width="2dp"
                    android:color="@color/colorDarkGrey"/>
            </shape>
        </item>
        <item >
            <bitmap android:gravity="bottom|right"
            android:src="@drawable/ic_arrow_drop_down_black_24dp" />
        </item>
      </layer-list></item>
    </selector>
    

    Preview:

    0 讨论(0)
提交回复
热议问题