我有一個對話框佈局如下:滾動的Android的ListView中的TableView行
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/categorylist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow>
<ListView
android:id="@+id/categorylistview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
/>
</TableRow>
<TableRow>
<TextView
android:text="New Category"
...
</TextView>
</TableRow>
<TableRow>
<EditText
android:id="@+id/NewCategoryEditText"
...
</EditText>
</TableRow>
<TableRow>
<Button
android:id="@+id/newcategorybutton"
...
/>
</TableRow>
</TableLayout>
我想ListView的生長,直到使用了可用空間,然後滾動,因爲它coninues增長。這工作得很好,當使用ListView錶行是最後一個在TableLayout:
alt text http://heeroz.com/scroll2.png
然而,在列表的頂部具有添加按鈕是不是很直觀。當我將「固定」表格行移動到底部時,ListView會在屏幕長到應該滾動的位置時將它們從屏幕上推開。只有ListView控件將開始滾動時有可推離屏幕沒有別的左:
alt text http://heeroz.com/scroll1.png
我怎樣才能改變我的佈局,以便與按鈕和的EditText視圖中的錶行仍在可見?
我不記得一個特別的原因,我會嘗試你的建議。謝謝。 – cdonner 2010-07-03 04:08:22
效果更好,到目前爲止我還沒有發現任何缺點。謝謝! – cdonner 2010-07-04 00:39:39
使用layout_weight時,請記住使用layout_width =「0dp」 – Peter 2014-02-06 13:58:51