4

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.

TokTok123
  • 753
  • 3
  • 11
  • 27

2 Answers2

7

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

MilapTank
  • 9,988
  • 7
  • 38
  • 53
4

Try out the Below

  <?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="90%"
            android:pivotY="-50%" >
            <shape
                android:shape="rectangle"  >
                <stroke android:color="@android:color/transparent" android:width="1dp"/>
                <solid
                    android:color="#ffffff"  />
            </shape>
        </rotate>
    </item>
</layer-list>
Biplab
  • 564
  • 1
  • 5
  • 19
  • 1
    @ArMo 372Play with rotate properties as below.. android:fromDegrees="-45" android:toDegrees="45" android:pivotX="270%" android:pivotY="70%" up facing trangle – Biplab Feb 12 '16 at 14:11