Android 通过 shape 实现三角形气泡效果_android shape 三角形_hust_twj的博客-CSDN博客

正三角形的 triangle_up.xml 如下: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 正三角 --> <item> <rotate android:fromDegrees="45" android:pivotX="-40%" android:pivotY="80%"> <shape android:shape="rectangle"> <size android:width="16dp" android:height="16dp" /> <solid android:color="#7d72ff" /> </shape> </rotate> </item> </layer-list> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 倒三角形的 triangle_down.xml 如下: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 倒三角 --> <item> <rotate android:fromDegrees="45" android:pivotX="135%" android:pivotY="15%"> <shape android:shape="rectangle"> <size android:width="16dp" android:height="16dp" /> <solid android:color="#7d72ff" /> </shape> </rotate> </item> </layer-list>