我一直在试图创建以下箭头,但更短,没有尾巴并指向下方。但无济于事。Android drawable xml:绘制箭头
有人可以帮我吗?我卡住了,无法弄清楚。我是否需要用代码而不是XML创建形状,或者我只是在创建合适的XML时失败。
我觉得没有必要发布我的代码,因为它与访问链接时发现的代码没有任何区别。
Android triangle (arrow) defined as an XML shape
我一直在试图创建以下箭头,但更短,没有尾巴并指向下方。但无济于事。Android drawable xml:绘制箭头
有人可以帮我吗?我卡住了,无法弄清楚。我是否需要用代码而不是XML创建形状,或者我只是在创建合适的XML时失败。
我觉得没有必要发布我的代码,因为它与访问链接时发现的代码没有任何区别。
Android triangle (arrow) defined as an XML shape
的NinePatch类许可证在九个或更多个部分绘制的位图。从本质上讲,它允许创建自定义图形,按照您定义的方式缩放 。
看看这里 http://developer-dot-android.blogspot.com.es/2012/03/android-9-patch-image-tutorial.html 这里 http://blog.fenrir-inc.com/us/2012/02/android-design-enlarge-images-with-nine-patch.html
了解如何做一个9patch图像。
然后,你可以用任何图形程序(如Photoshop中)创建你的箭头,使用this online tool或official SDK tool使其伸展
下应该努力让你向上箭头:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="87%" >
<shape
android:shape="rectangle" >
<stroke android:color="@color/transparent" android:width="10dp"/>
<solid
android:color="@color/your_color_here" />
</shape>
</rotate>
</item>
</layer-list>
找到的:https://looksok.wordpress.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/
为什么不使用图像呢? – Saqib
我可以,但是当支持所有屏幕尺寸并且不得不为所有尺寸创建相同的图像时,看起来像是很多努力,因为我在编码方面比创建图像更好。我也喜欢XML变体的可定制性。 – Orion
您必须创建其他分辨率的最大和最小尺寸。我认为这不是什么大问题 – Blackbelt