2014-01-09 74 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

請問您能解釋一下嗎? –