易于绘制的箭头图标

4
我花了数小时尝试使用各种旋转方式制作下面的箭头,但毫无成功,它看起来根本不像这样: The insanely difficult arrow 使用shape/layer-list而不使用png,是否有可能制作出它?
*编辑*
我能做到最接近期望箭头的是这个。但我永远不能使线条匹配而且不重叠: My best try

1
Android 5.0+上的VectorDrawable应该能够处理这个。据说官方的回溯版本正在开发中,同时你可以在此期间使用这个库 - CommonsWare
不理解你的问题,请详细说明。 - Jamil
你不想使用PNG drawable,有特别的原因吗? - Squonk
@Softcoder,我已经更新了问题。 - Amio.io
@Squonk 是的,灵活性和大小。我需要箭头有3种颜色X状态。 - Amio.io
1个回答

8
也许这就是你正在寻找的内容。

arrow.xml

箭头.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="100%"
            android:pivotY="50%"
            android:toDegrees="-45">
            <shape
                android:shape="line">
                <stroke
                    android:width="3dp"
                    android:color="@android:color/holo_green_light"
                    />
            </shape>
        </rotate>
    </item>

    <item>
        <rotate
            android:fromDegrees="45"
            android:pivotX="100%"
            android:pivotY="50%"
            android:toDegrees="45">
            <shape
                android:shape="line">
                <stroke
                    android:width="3dp"
                    android:color="@android:color/holo_green_light"
                    />
            </shape>
        </rotate>
    </item>
</layer-list>

如果您的边缘没有粘合,您可以为元素添加顶部和底部。对于第一个元素,请添加<item android:bottom="5dp">,对于第二个元素,请添加<item android:top="4dp">


添加了一个编辑功能,可以使行尾紧密粘合。 - Vilen
@Villen Melkumyan,恭喜你赢得了比赛!;) 两天内奖励将会发放。我通常会记得的,如果不记得,请在这里提醒我。 - Amio.io

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