2012-09-16 35 views
0

我試圖實現一個垂直的LinearLayout,其中底部固定寬度欄,頂部固定寬度欄,中間區域佔據空間的其餘部分。在天真實施LinearLayout中的頁眉和頁腳

<LinearLayout android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <View android:layout_height="50sp"/> 

    <View android:layout_height="fill_parent"/> 

    <View android:layout_height="50sp"/> 
</LinearLayout> 

頂部的酒吧在那裏,但底部欄是不可見的。我猜佈局過程在中間視圖中遇到了fill_parent,併爲其分配了其餘的垂直空間。

是否有某種重力/重量技巧會使佈局識別並顯示底部條?

回答

2

嘗試使用重量設置中間部分的高度,像這樣。

<View android:layout_height="50dp"/> 

<View android:layout_height="0dp" 
     android:layout_weight="1" 
/> 

<View android:layout_height="50dp"/> 

這將繪製的頂部和底部的第一和比填充所有(重量= 「1」)剩餘高度與圖