如何创建渐变边框颜色

How can I create gradient border color

我正在寻找创建类似下面按钮的东西:

我知道如何创建它,但我想要它具有渐变边框颜色。

试试这个:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <!-- create gradient you want to use with the angle you want to use -->
        <shape android:shape="rectangle">
            <gradient
                android:angle="0"
                android:centerColor="@android:color/holo_blue_bright"
                android:endColor="@android:color/holo_red_light"
                android:startColor="@android:color/holo_green_light" />
            <corners android:radius="@dimen/dp_10"/>

        </shape>
    </item>
    <!-- create the stroke for top, left, bottom and right with the dp you want -->
    <item
        android:bottom="2dp"
        android:left="2dp"
        android:right="2dp"
        android:top="2dp">
        <shape android:shape="rectangle" >
            <!-- fill the inside in the color you want (could also be a gradient again if you want to, just change solid to gradient and enter angle, start, maybe center, and end color) -->
            <solid android:color="#fff" />
            <corners android:radius="@dimen/dp_10"/>
        </shape>
    </item>

</layer-list>

选择你想要的颜色..