Android drawable 三角形
2023-03-09 14:40:42
michael007js
556
正三角
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/shape_id"> <!-- 正三角 --> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="80%"> <shape android:shape="rectangle"> <solid android:color="#000000"/> </shape> </rotate> </item> </layer-list>
倒三角
shape_reverse_triangle.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/shape_id"> <!-- 倒三角 --> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="135%" android:pivotY="15%" > <shape android:shape="rectangle"> <solid android:color="#000000"/> </shape> </rotate> </item> </layer-list>
使用
<ImageView android:layout_width="18dp" android:layout_height="18dp" android:background="@drawable/shape_reverse_triangle"/>