Search code examples
androidxmlandroid-xmlandroid-drawablexml-drawable

Curve drawable without vector - xml Android


I am trying to draw this on xml drawable:

enter image description here

With Vector it is easy but it is showing "concurrent mark sweep GC" on logcat and it is causing the device to slow-down.

Thank you.


Solution

  • Try this way

    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="180"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="180">
        <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
            <item
                android:left="-100dp"
                android:right="-100dp"
                android:top="-80dp">
    
    
                <shape android:shape="oval">
                    <size android:height="20dp" />
                    <gradient
                        android:angle="0"
                        android:centerColor="@color/colorAccent"
                        android:endColor="@color/colorPrimary"
                        android:startColor="@color/colorPrimary"
                        android:type="linear" />
                </shape>
    
    
            </item>
    
            <item>
                <shape android:shape="rectangle" />
            </item>
    
        </layer-list>
    
    </rotate>
    

    OUTPUT

    enter image description here