Search code examples
androiddrawableandroid-vectordrawable

half rectangle shape drawable shapes android


I use this drawable code:

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

And the output is :

Shape preview after run above code

I want only one little change, i need to show this half square at right like this one :

Required shape preview


Solution

  • I think this will solve your issue:-

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