1

I'm trying to draw a rectangle with one shorter side like in the image below:

enter image description here

This is what I have for the moment, but my code doesn't work all I'm drawing is a black rectangle.

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

1 回答 1

2

你可以旋转一个矩形。只需将负填充调整到您想要的大小。

<?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>
于 2015-06-16T00:38:48.853 回答