2014-01-09 73 views
0

我正在设计应用程序的UI,并希望将我的布局分为4个部分。 (使用两条正交线)。旋转笔画不填充高度

布局的背景必须是sweep型gradiant颜色象下面这样:

<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> 

要创建垂直线,我使用从rotatestroke如下:

<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> 

现在,我将两个可绘制并创建如下背景:

<?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> 

好吧,设置布局背景后,我的背景是:

enter image description here

正如你在图像上看到,水平线不填充屏幕。所以为什么 ?! 请给我一个解决方案来解决我的问题。

感谢提前:)

回答

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 ...> 
+0

您的解决方案对我无效! –

+0

增加了另外一个建议 – FunkTheMonk

+0

请问您能解释一下吗? –