如何创建这个形状drawable

时间:2016-06-15 06:20:40

标签: android android-layout android-xml android-drawable

我想创建xml drawable到这个形状,

enter image description here

1 个答案:

答案 0 :(得分:2)

使用此布局并保存在可绘制文件夹中.....

<?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>

并在布局视图中设置为背景....

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

注意: - 将宽度和高度设置为wrap_content .....

Image

享受编码...........

相关问题