我正在设计应用程序的UI,并希望将我的布局分为4个部分。 (使用两条正交线)。
布局背景必须是sweep
类型渐变色,如下所示:
<shape android:shape="rectangle" >
<gradient
android:centerColor="@color/gradiant_center_color"
android:endColor="@color/gradiant_end_color"
android:startColor="@color/gradiant_start_color"
android:type="sweep" />
</shape>
要创建正交线,我使用的是rotate
和stroke
,如下所示:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="90"
android:pivotX="50%"
android:pivotY="50%" >
<shape android:shape="line" >
<stroke
android:width="1dip"
android:color="@color/separator_color" />
</shape>
</rotate>
</item>
<item>
<shape
android:shape="line" >
<stroke
android:width="1dp"
android:color="@color/separator_color" />
</shape>
</item>
</layer-list>
现在,我将两个drawable组合在一起并创建如下背景:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<gradient
android:centerColor="@color/gradiant_center_color"
android:endColor="@color/gradiant_end_color"
android:startColor="@color/gradiant_start_color"
android:type="sweep" />
</shape>
</item>
<item android:drawable="@drawable/separator_border"/>
</layer-list>
好的,在设置布局背景后,我的背景是:
正如您在图像上看到的那样,水平线不会填满屏幕。所以为什么 ?! 请给我一个解决方案来解决我的问题。
提前致谢:)
答案 0 :(得分:0)
线条形状绘制水平线,绘制宽度的长度,然后旋转90度(2条线的长度相同)。
您可以将<size width="999999dp" height="1dp" />
置于轮换的<shape>
或者,
将<scale>
包裹在<rotate>
或其中(包裹<shape>
)
<rotate ...>
<scale scaleWidth="200%" scaleHeight="100%">
<shape ...>
或
<scale scaleWidth="200%" scaleHeight="100%">
<rotate ...>
<shape ...>