Pregunta

I would like to draw a triangle on the upper right corner of a gridview item as a marker. I can do this with a background image but would like to use shape drawing with xml because this way things look more georgeous :D

¿Fue útil?

Solución

Use below 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="-40%"
                android:pivotY="87%" >
                <shape
                    android:shape="rectangle" >
                    <stroke android:color="@color/transparent" android:width="10dp"/>
                    <solid
                        android:color="@color/your_color_here" />
                </shape>
            </rotate>
        </item>
    </layer-list>

Otros consejos

There are already numerous resources available on the internet , However, the first link mentioned was helpful to me. However u can check below ones!

This link might help u out in achieving the goal.

Using Android Specification to draw triangle.

or drawing Triangle Using Canvas

Drawing Triangle Using Canvas

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top