Android – Drawing triangle in XML

android

In XML I'm attempting to draw a drop down triangle to be used as a background for a button but cant seem to get my head round the rotate XML tags.

Here's my XML code:

    <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <rotate
            android:fromDegrees="45"
            android:toDegrees="45"
            android:pivotX="80%"
            android:pivotY="20%">
            <shape
                android:shape="rectangle" >
                <solid
                    android:color="#FFCC00" />
            </shape>
        </rotate>
    </item>
</layer-list>

And here's the outcome of the XML:

enter image description here

Any ideas are appreciated.

Best Solution

i can draw triangle shape using XML triangle .xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <rotate
        android:fromDegrees="45"
        android:pivotX="-40%"
        android:pivotY="87%"
        android:toDegrees="45" >
        <shape android:shape="rectangle" >
            <stroke
                android:width="10dp"
                android:color="#00000000" />

            <solid android:color="#00ACED" />
        </shape>
    </rotate>
</item>
</layer-list>

triangle

Related Question