Diamond shape xml background for android view


Hi anyone please suggest me how to create android xml drawable like below image?

enter image description here

Now I am using below code

<?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="-40%"
            android:pivotY="87%"
            android:toDegrees="45">
            <shape android:shape="rectangle">
                <stroke
                    android:width="10dp"
                    android:color="@color/colorAccent" />
                <solid android:color="@color/colorAccent" />
            </shape>
        </rotate>
    </item>
</layer-list>

but its result is triangle but I need above shape.


Answers:


Check this,

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:left="43dp"
    android:top="43dp"
    android:right="43dp"
    android:bottom="43dp">
    <rotate android:fromDegrees="45">
        <shape>
            <size
                android:width="200dp"
                android:height="200dp" />
            <gradient
                android:startColor="#0fdcc9"
                android:endColor="#0fdcc9" />
            <stroke
                android:width="5dp"
                android:color="#2DACA0" />
        </shape>
    </rotate>
</item>
</layer-list>