如何创建一个右箭头使用XML形状的Android面对? [英] How to create a right facing arrow using xml shapes in android?
本文介绍了如何创建一个右箭头使用XML形状的Android面对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建使用XML形状的Android这样的箭头的权利??
How to create a right facing arrow using xml shapes in android like this??
推荐答案
我有一个类似的问题。以下是我解决了它:
I've had a similar problem. Here's how I solved it:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="@android:color/transparent"/>
<size android:width="2dp" android:height="50dp"/>
</shape>
</item>
<item android:bottom="20dp">
<rotate
android:fromDegrees="-45"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="@android:color/black"/>
<corners
android:radius="1dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"/>
</shape>
</rotate>
</item>
<item android:top="20dp">
<rotate
android:fromDegrees="45"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="@android:color/black"/>
<corners
android:radius="1dp"
android:topRightRadius="0dp"
android:topLeftRadius="0dp"/>
</shape>
</rotate>
</item>
</layer-list>
第一项是一个空的形状,以扩大可绘制。然后,我用2矩形。他们每个人都有2面圆。
The first item is an empty shape to expand the drawable. Then, I've used 2 rectangles. Each of them has 2 sides rounded.
您需要通过的ImageView
来使用这个绘制:
You need to use this drawable via an ImageView
:
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/arrow"
android:contentDescription="@string/arrow_descriptor"/>
下面的结果:
注意: AndroidStudio不会呈现不同角落的大小,但它显示了正确的设备
Note: AndroidStudio doesn't render different corner sizes, but it shows up properly on devices.
这篇关于如何创建一个右箭头使用XML形状的Android面对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文