Search code examples
androidandroid-drawablexml-drawablelayer-list

Layer list containing circle with outer stroke


I would like to create the following background with a layer-list:

enter image description here

So basically a circle which has an outer stroke border. I created the following XML:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <solid android:color="#fff"/>
            <size
                android:width="10dp"
                android:height="10dp"/>
        </shape>
    </item>

    <item>
        <shape android:shape="oval">

            <stroke android:color="#ff" android:width="2dp"/>
            <size
                android:width="25dp"
                android:height="25dp"/>
        </shape>
    </item>
</layer-list>

But this shows only one solid oval. Any help is appreciated!


Solution

  • Try This Change Color as per your requirement

        <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:width="60dp"
            android:height="60dp"
            android:top="15dp"
            android:right="15dp"
            android:bottom="15dp"
            android:left="15dp">
            <shape
                android:shape="oval">
                <solid android:color="#ffffff" />
            </shape>
        </item>
        <item>
            <shape
                android:shape="oval">
                <stroke android:width="8dp"
                    android:color="#ffffff"/>
            </shape>
        </item>
    </layer-list>