How to create shape in android using xml? and can we arrange those triangles as circle?
Asked
Active
Viewed 1.1k times
5

Vadim Kotov
- 8,084
- 8
- 48
- 62

Sridhar T Saminathan
- 210
- 1
- 3
- 11
-
this link maybe helpful https://stackoverflow.com/a/18421795/8164071 – Pritesh - ɐʎıɥpɐΛ ɥsǝʇᴉɹꓒ Jun 21 '17 at 05:43
-
https://github.com/adityasd/ButtonShapes – Aditya Vyas-Lakhan Jun 21 '17 at 06:48
1 Answers
7
Try this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/rightArrow">
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="87%" >
<shape
android:shape="rectangle" >
<stroke android:color="@android:color/transparent" android:width="10dp"/>
<solid
android:color="#000000" />
</shape>
</rotate>
</item>
</layer-list>
For the desired direction of triangle you can play with the degrees and pivotx/y points
e.g
<rotate
android:fromDegrees="220"
android:toDegrees="0"
android:pivotX="35%"
android:pivotY="5%" >
<shape
android:shape="rectangle" >
<stroke android:color="#000000" android:width="1dp"/>
<solid
android:color="#000000" />
</shape>
</rotate>
will give you 'v' shaped triangle
alternate for rotate this property also given v shape triangle
android:rotation="180"

Bhuvaneshwaran Vellingiri
- 569
- 1
- 10
- 21

Ichigo Kurosaki
- 3,765
- 8
- 41
- 56