Search code examples
androidxmlsvgvectordrawable

drawing a triangle using Vector path and XML in android


I have found how to draw a triangle, but I need to rotate it now and I can't seem to make it..

My goal is to reach this:

enter image description here

So far I have found this code:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="40dp"
    android:height="40dp"
    android:viewportHeight="100"
    android:viewportWidth="100">
    <group android:name="triableGroup">
        <path
            android:name="triangle"
            android:fillColor="@color/some_color"
            android:pathData="m 50,0 l 50,50 -100,0 z" />
    </group>
</vector>

but it appears like this :

enter image description here


Solution

  • One way is to add these attributes in group :

    android:pivotX="50"
    android:pivotY="50"
    android:rotation="45"