斜spilliting一个相对布局的背景 [英] Diagonally spilliting background of a Relative Layout
本文介绍了斜spilliting一个相对布局的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好所有我想要布局的背景如下:
现在我在做什么是如下,
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目
机器人:可绘制=@色/ blue_new>
< /项目><项目>
<旋转
机器人:fromDegrees =45
机器人:toDegrees =0
机器人:pivotX =0%
机器人:pivotY =100%>
<形状
机器人:形状=矩形>
[固体机器人:色=@色/白/> < /形状>
< /旋转>
< /项目><项目>
<旋转
机器人:fromDegrees = - 45
机器人:toDegrees =0
机器人:pivotX =130%
机器人:pivotY =0%>
<形状
机器人:形状=矩形>
[固体机器人:色=@色/白/> < /形状>
< /旋转>
< /项目>< /层列表>
现在我得到的部分我想要什么。如果我删除第三个项目,该矩形没有到达另一端。是否有任何其他方式做到这一点?其他然后9patch形象?我能动态计算的第二和第三项的pivotX和pivoty值?或者有没有其他的方法来做到这一点。
感谢。
解决方案
<?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目
机器人:可绘制=@机器人:彩色/黑白>
< /项目><项目>
<旋转
机器人:fromDegrees =55
机器人:pivotX =10%
机器人:pivotY =85%
>
<形状 机器人:形状=矩形>
[固体机器人:颜色=#FFFFFF/> < /形状>
< /旋转>
< /项目>< /层列表>
试试这个。
Hello all i want background of a layout as follows.
Now what i am doing is follows,
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@color/blue_new">
</item>
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="0"
android:pivotX="0%"
android:pivotY="100%" >
<shape
android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</rotate>
</item>
<item>
<rotate
android:fromDegrees="-45"
android:toDegrees="0"
android:pivotX="130%"
android:pivotY="0%" >
<shape
android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</rotate>
</item>
</layer-list>
Now i am partially getting what i want. If i remove third item, the rectangle is not reaching another end. Is there any other way to do it? Other then 9patch image? Can i dynamically calculate the pivotX and pivoty values of the second and third item? Or is there any other method to do so.
Thanks.
解决方案
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@android:color/black">
</item>
<item>
<rotate
android:fromDegrees="55"
android:pivotX="10%"
android:pivotY="85%"
>
<shape
android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
</layer-list>
try this.
这篇关于斜spilliting一个相对布局的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文