Set gradient on stroke android

If you need inner color to be transparent, then you can use a ring shape:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:thickness="2dp"
    android:useLevel="false">
    <gradient
        android:startColor="@color/sea_green"
        android:endColor="@color/black"
        android:angle="270" />
</shape>

enter image description here


You should do something like this. Use layer-list with 2 shapes. First one is for gradient stroke and second one is for solid.

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="oval" >
            <gradient
                android:angle="360"
                android:startColor="#543456"
                android:endColor="#ff00b5"
                android:type="linear" />
            <size android:width="24dp"
                  android:height="24dp"/>
        </shape>
    </item>

    <item
        android:bottom="2dp"
        android:left="2dp"
        android:right="2dp"
        android:top="2dp">
        <shape android:shape="oval" >
            <solid android:color="#fff" />
        </shape>
    </item>

</layer-list>

This code looks like this enter image description here