2013-03-01 61 views
0

我想實現一個滾動視圖和固定底部欄的佈局。底部欄有一個固定的高度,滾動視圖應該佔用屏幕的剩餘高度,但不應該增長任何內容的高度(因爲它應該滾動內容)。scrollview進入gridlayout單元格:如何防止它垂直增長?

我試了很多佈局組合,但我無法找到正確的。

如果我使用LinearLayout和layout_weight技巧,問題是一樣的。

在下面的示例中:將線性佈局中的android:minHeight =「600dp」更改爲300dp,並且它將正常工作。在這個例子中,爲什麼scrollview的高度增長很多?

<?xml version="1.0" encoding="utf-8"?> 
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:rowCount="2" 
android:background="#fff" 
android:columnCount="1" 
android:orientation="vertical"> 
<ScrollView 
    android:id="@+id/zoneContent" 
    android:background="#00f" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="fill_horizontal" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:background="#f00" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:orientation="vertical" 
     android:minHeight="600dp" /> 
</ScrollView> 
<GridLayout 
    android:layout_height="70dp" 
    android:layout_width="240dp" 
    android:layout_gravity="center_horizontal|fill_vertical" 
    android:background="#0f0" 
    android:rowCount="1" 
    android:layout_column="0" 
    android:columnCount="5" 
    android:layout_row="1" /> 
</GridLayout> 

回答

0

這似乎這樣的伎倆

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#fff" 
android:orientation="vertical"> 
<ScrollView 
    android:id="@+id/zoneContent" 
    android:background="#00f" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:layout_gravity="fill_horizontal" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:background="#f00" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:orientation="vertical" 
     android:minHeight="300dp" /> 
</ScrollView> 
<GridLayout 
    android:layout_height="70dp" 
    android:layout_width="240dp" 
    android:layout_gravity="center_horizontal|fill_vertical" 
    android:background="#0f0" 
    android:rowCount="1" 
    android:layout_column="0" 
    android:columnCount="5" 
    android:layout_row="1" /> 
</LinearLayout> 
0

採取的LinearLayout作爲父佈局,而不是網格佈局,然後固定佈局的重量。

相關問題