如何创建一条短边的矩形?

How to create rectangle with one shorter side?

我正在尝试绘制一个有一个较短边的矩形,如下图所示:

这就是我目前拥有的,但我的代码无法正常工作我正在绘制的是一个黑色矩形。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke
        android:width="1dp"
        android:color="#000000" />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp"/>
</shape>

您可以旋转一个矩形。只需将负边距调整到您想要的大小即可。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:top="-500dp">
        <rotate
            android:fromDegrees="-55"
            android:pivotX="100%"
            android:pivotY="100%">
            <shape android:shape="rectangle">
                <solid android:color="#000" />
            </shape>
        </rotate>
    </item>
</layer-list>