android 自定义形状作为背景可绘制对象

android custom shape as background drawable

我正在尝试绘制下面的蓝色形状。 我希望我的对话框具有这种自定义的蓝色形状。但我想不通。 我试过下面的代码。

非常感谢您的提示,谢谢

<item>
    <rotate
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="0">
        <shape android:shape="rectangle">
            <solid android:color="@color/red_color" />
        </shape>
    </rotate>

</item>

<item>
    <rotate
        android:fromDegrees="-10"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="-10">
        <shape android:shape="rectangle">
            <solid android:color="@color/gray_color" />
        </shape>
    </rotate>
</item>

表示倾向

这是我上面的代码的结果:

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

<item android:top="87dp"
    android:bottom="-300dp"
    android:left="0dp"
    android:right="-300dp">
    <rotate
        android:fromDegrees="-10"
        android:pivotX="0%"
        android:pivotY="100%">
        <shape
            android:shape="rectangle">
            <solid
                android:color="@android:color/holo_blue_light"/>
        </shape>
    </rotate>
</item>

使用上面的代码,您将实现倾斜。注意:根据需要更改颜色代码。 觉得有用就点个赞吧