制作使用XML定义一个三角形? [英] Making a triangle shape using xml definitions?
本文介绍了制作使用XML定义一个三角形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法,我可以在XML文件中指定一个三角形的方式?
Is there a way that I can specify a triangle shape in an xml file?
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="triangle">
<stroke android:width="1dip" android:color="#FFF" />
<solid android:color="#FFF" />
</shape>
我们能做到这一点的,路径形状的东西?我只是需要一个等边三角形。
can we do this with a path shape or something? I just need an equilateral triangle.
感谢
推荐答案
In this post I describe how to do it. And here is the XML defining triangle:
<?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>
请参考我的文章,如果事情是不明确或者你需要解释它是如何构建的。它旋转的切口矩形:)这是非常聪明和好工作的解决方案。
Refer to my post if something is unclear or you need explanation how it is built. It is rotated an cutout rectangle :) it is very smart and well working solution.
编辑: 创建一个箭头指向像 - >使用:
to create an arrow pointing like --> use:
...
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="13%"
android:pivotY="-40%" >
...
和创建一个箭头指向像&LT; - 使用:
And to create an arrow pointing like <-- use:
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="87%"
android:pivotY="140%" >
这篇关于制作使用XML定义一个三角形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文