Android 相对布局的对角溢出背景
您好,我想要一个布局的背景如下 现在我要做的是Android 相对布局的对角溢出背景,android,android-layout,background,Android,Android Layout,Background,您好,我想要一个布局的背景如下 现在我要做的是 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@color/blue_new"> </item> <item> <rotate android:fromDegrees="45" android:to
<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>
现在我部分得到了我想要的。如果删除第三项,则矩形不会到达另一端。还有别的办法吗?其他的补丁图像?我可以动态计算第二项和第三项的pivotX和pivoty值吗?或者是否有其他方法可以做到这一点
谢谢。
<?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>
试试这个。
试试这个。maim.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TestActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
style="@style/diagonalStyle">
</RelativeLayout>
style.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="diagonalStyle">
<item name="android:background">@drawable/background</item>
</style>
@可绘制/背景
background.xml
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="50%"
android:pivotY="50%" >
<shape
android:shape="line"
android:top="1dip" >
<stroke
android:width="1dip"
android:color="#FF0000" />
</shape>
</rotate>
试试这个,它可以工作maim.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TestActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
style="@style/diagonalStyle">
</RelativeLayout>
style.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="diagonalStyle">
<item name="android:background">@drawable/background</item>
</style>
@可绘制/背景
background.xml
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="50%"
android:pivotY="50%" >
<shape
android:shape="line"
android:top="1dip" >
<stroke
android:width="1dip"
android:color="#FF0000" />
</shape>
</rotate>
试试这个,它能用对不起,同样的问题。仅适用于少数设备,但不适用于所有设备。我想我必须使用9个补丁图片。对不起,同样的问题。仅适用于少数设备,但不适用于所有设备。我想我必须使用9个补丁图片。是的。。。工作如果你想在没有图像的设计中应用静态“度”,你需要是一个法师(例如:)是的。。。工作如果你想在没有图像的设计中应用静态“度”,你需要是一个法师(例如:)