androidandroid-shapeandroid-shapedrawable

Shape drawable not working?


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:thickness="3dp"
    android:innerRadius="34dp">

    <solid android:color="@color/colorAccent"/>

</shape>

I want to create ring but nothing appears.


Solution

  • use this code,

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

    using ring shape

    <?xml version="1.0" encoding="utf-8"?>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="ring"
        android:innerRadius="15dp"
        android:thickness="10dp"
        android:useLevel="false">
        <solid android:color="#ff0000" />
    
    </shape>