Create a rounded triangle

I need to create a rounded triangle. Here is my code

<item android:gravity="center"> <rotate android:fromDegrees="45" android:pivotX="-40%" android:pivotY="87%" android:toDegrees="45" > <shape android:shape="rectangle" > <corners android:radius="2dp"/> <solid android:color="#ffffff" > </solid> <stroke android:color="#ffffff" /> </shape> </rotate> </item> 

with my code, only one side of the triangle is rounded, the other two corners are not rounded. Please help me create a triangle with all angles.

+6
source share
1 answer

enter image description here

Create triangle.xml in res/drawable

 <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="50dp" android:width="50dp" android:viewportHeight="16.0" android:viewportWidth="16.0" > <path android:fillColor="@color/colorAccent" android:pathData="M11.844,9.04L8.345,5.163c-0.195,-0.217 -0.511,-0.217 -0.705,0l-0.012,0.02L4.136,9.04c-0.195,0.217 -0.195,0.569 0,0.786l0.006,0.005C4.233,9.936 4.358,10 4.499,10h6.983c0.143,0 0.27,-0.068 0.359,-0.176l0.002,0.002C12.039,9.609 12.039,9.257 11.844,9.04z"/> </vector> 

change the color of the triangle by changing android:fillColor

and use @drawable/triangle

it's easy. because simple drawables do not have preliminary functions for changing the form.

+4
source

All Articles