半矩形可绘制形状 android

half rectangle shape drawable shapes android

我使用这个可绘制代码:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item  >
    <rotate
        android:fromDegrees="45"
        android:toDegrees="10"
        android:pivotX="100%"
        android:pivotY="-0%">
        <shape
            android:shape="rectangle"   >
            <solid
                android:color="@color/text_color"  />
        </shape>

    </rotate>
</item>

输出为:

Shape preview after run above code

我只想要一点零钱,我需要像下面这样在右边显示半个正方形:

Required shape preview

我认为这将解决您的问题:-

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item  >
    <rotate
        android:fromDegrees="-45"
        android:toDegrees="45"
        android:pivotX="0%"
        android:pivotY="0%">
        <shape
            android:shape="rectangle"   >
            <solid
                android:color="@color/text_color"  />
        </shape>

    </rotate>
</item>