如何在Android XML中绘制三角形形状

5

三角形图片
如何使用xml在android中创建形状?并且我们可以将这些三角形排列成圆形吗?


这个链接可能会有帮助 https://dev59.com/4HE85IYBdhLWcg3w_Itr#18421795 - Pritesh - ɐʎıɥpɐΛ ɥsǝʇᴉɹꓒ
https://github.com/adityasd/ButtonShapes - Aditya Vyas-Lakhan
1个回答

7

试试这个

<?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>

对于所需的三角形方向,您可以根据度数和枢轴点pivotx/y进行调整。

例如:

<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>

将会给你一个'v'形的三角形

替代旋转 这个属性也将给出 V 形的三角形

android:rotation="180"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接