I need to create triangle with rounded corners. 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 triangle is rounded, other two corners not rounded. Please help me to create triangle all corners rounded.
A Reuleaux Triangle is a plump triangle with rounded edges, formed in the following way: take the three points at the corners of an equilateral triangle, and connect each pair of points by a circular arc centered at the remaining point. This triangle has some amazing properties.
If you want to generate a triangle with rounded corners, the code is at least , and the best way is to use SVG to generate it. Use SVG's polygon tag <polygon> generate a triangle, and use SVG's stroke-linejoin="round" generate rounded corners at the connection.
Create triangle.xml
into 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 color of triangle by changing android:fillColor
and use @drawable/triangle
it's easy way.... because simple drawable doesn't have advance features for shape modification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With