2012-06-01 45 views
5

我有以下線性佈局身高和體重

<linearLayout> 
<RelativeLayout> 
    <!-- Header --> 
</RelativeLayout> 

<linearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:weightSum="6"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

</linearLayout> 

但佈局不承擔填補了高度妥善我想爲一個的LinearLayout的預期效果低於另一個,並採取了母體空間的1/6。

相反,它似乎是將重量應用到元素的寬度。

在Android中假設百分比高度的正確方法是什麼?寬度似乎是一個輕而易舉的重量,但我似乎無法得到正確的高度。

+1

對我來說看起來是正確的...哦,請嘗試在父LinearLayout上指定'orientation:vertical'。 –

+0

我有同樣的問題,扭曲。在我的情況下,根linearlayout混合了線性佈局,framelayout和相對佈局。任何線索我要去哪裏錯了。我已經在所有線性佈局中指定了方向。 –

回答

11

在您的LinearLayout中加上android:orientation="vertical",因爲默認情況下它是android:orientation="horizontal"

+0

一個簡單的錯過減速,謝謝隊友 – Xavier

+0

它的工作原理,但我的情況:我有3個班輪佈局內其他和他們沒有相同的高度 –