How to draw right Triangles shape in android xml
Updated, Now a Right angle triangle
This will work for sure
1
- This code will make a left sided triangle like in the photo above.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="52"
android:toDegrees="45"
android:pivotX="-45%"
android:pivotY="90%" >
<shape
android:shape="rectangle" >
<solid
android:color="@color/colorPrimary"/>
</shape>
</rotate>
</item>
</layer-list>
2
- This code will make a Right sided triangle like in the photo above.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="-50"
android:toDegrees="45"
android:pivotX="140%"
android:pivotY="90%" >
<shape
android:shape="rectangle" >
<solid
android:color="@color/colorPrimary"/>
</shape>
</rotate>
</item>
</layer-list>
Try this one
Also check my another answer How to create vector drawable in android studio
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="113dp"
android:viewportWidth="108"
android:viewportHeight="113">
<path
android:pathData="M2.423,111.534L105.599,110.724L1.032,3.022L2.423,111.534Z"
android:strokeWidth="2"
android:fillColor="#ffffff"
android:strokeColor="#000000"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="119dp"
android:height="126dp"
android:viewportWidth="119"
android:viewportHeight="126">
<path
android:strokeWidth="1"
android:pathData="M117.632,124.928L1.686,125.144L118.003,2.092L117.632,124.928Z"
android:fillColor="#ffffff"
android:strokeColor="#000000"/>
</vector>