1

我有以下对话框布局:

<?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 增长直到可用空间被使用,然后随着它继续增长而滚动。当具有 Listview 的表行是 TableLayout 中的最后一行时,这可以正常工作:

替代文字
(来源:heeroz.com

但是,将“添加”按钮放在列表顶部并不是很直观。当我将“固定”表格行移动到底部时,一旦 ListView 增长到应该滚动的点,它就会将它们推离屏幕。只有当没有其他东西可以从屏幕上推出时,ListView 才会开始滚动:

替代文字
(来源:heeroz.com

如何更改布局以使带有按钮的表格行和 EditText 视图保持可见?

4

1 回答 1

4

您使用 aTableLayout而不是LinearLayoutwith是否有特殊原因android:orientation="vertical"?如果你使用LinearLayout你可以指定你应该得到你想要的结果android:layout_weight="1"ListView

于 2010-07-03T04:05:50.853 回答