easy arrow as drawable

时间:2015-05-04 19:22:08

标签: android android-drawable

I have spent hours trying to make the below arrow using drawables using all kind of rotations without any success it simply never looked like it:

The insanely difficult arrow

Is it even possible to make it using shape/layer-list, without using png?

* EDIT *

The closest I could get to the desired arrow was this. I could never put the lines to match and NOT to overlap:

My best try

1 个答案:

答案 0 :(得分:8)

maybe this what you are looking for

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

in case you have edges not sticking you can add top and bottom to elements so for first one add <item android:bottom="5dp"> for second <item android:top="4dp"> ....