How to create this shape drawable

2019-06-04 05:58发布

问题:

I want to create xml drawable to this shape,

回答1:

use this layout and save in drawable folder.....

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

    <item>
        <shape android:shape="rectangle">
            <size
                android:width="200dp"
                android:height="50dp" />
            <solid android:color="#ef45d1" />
            <corners android:topRightRadius="20dp" />
        </shape>
    </item>


    <item
        android:bottom="0dp"
        android:right="165dp"
        android:top="0dp">

        <rotate
            android:fromDegrees="45"
            android:pivotX="0%"
            android:pivotY="0%"
            android:toDegrees="45">

            <shape android:shape="rectangle">
                <solid android:color="#ffffff" />


            </shape>
        </rotate>

    </item>

</layer-list>

and set in your layout view as background....

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:background="@drawable/newrecatngle"/>

NOTE:-set width and height as wrap_content.....

enjoy coding...........