How to draw rounded corner shape mentioned below in android drawable

Viewed 6708

I have tried with that code but seems not correct please help

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<rotate
android:fromDegrees="45"
android:pivotX="35%"
android:pivotY="30%">
<shape>
<size android:height="5dp" android:width="5dp"/>
<corners android:radius="0.5dp" />
<solid android:color="@color/white" />
</shape>
</rotate>
</item>

enter image description here

3 Answers

Probably it would be easier using a vector drawable:

<vector android:height="24dp" android:viewportHeight="101.01621"
    android:viewportWidth="114.45102" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#00000000"
        android:pathData="m0.421,7.319c-0.848,-4.225 2.893,-6.292 4.701,-6.534l93.265,-0.552c9.395,-0.736 15.906,2.42 15.875,15.875l-0.032,78.398c1.262,7.668 -11.009,7.894 -15.926,3.48 -17.528,-8.582 -70.939,-31.855 -92.048,-40.468 -1.899,-0.775 -3.147,-1.13 -4.14,-1.522 -2.225,-0.879 -2.097,-3.281 -1.851,-5.335z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
</vector>

enter image description here

If you need to make some adjustments, you shold download Inkscape (https://inkscape.org) or another svg design software and my source file (if your want) https://drive.google.com/open?id=1vY8tYcA00KAQeoulMlPmwvRWrs7EY672. Draw your shape and than export it again in svg. Once you have your file in svg format you can use vector asset tool from Android Studio. The tool generates automatically your vector xml and that you can use the vector drawable as a common drawable, for example as a source of an ImageView. Hope it helps!

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:topLeftRadius="12dp"
android:topRightRadius="12dp"
android:bottomLeftRadius="75dp"
android:bottomRightRadius="9dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#47A891"
android:startColor="#E8E8E8"
android:endColor="#000000"
android:type="linear"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="100dp"
android:height="100dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- view background color -->
    <solid
        android:color="#142737" >
    </solid>

    <!-- Here is the corner radius -->
    <corners
        android:radius="10dp"   >
    </corners>

place this xml file in drawable folder and set it as the background of the button like:
android:background="@drawable/oval_background"

Related