开发者

Scrollable Android ListView in TableView Row

I have the following layout for a dialog:

<?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:la开发者_如何学Pythonyout_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>      

I would like the Listview to grow until the available space is used, then scroll as it coninues to grow. This works fine when the table row with the Listview is the last one in the TableLayout:

Scrollable Android ListView in TableView Row

(source: heeroz.com)

However, having the Add button at the top of the list is not very intuitive. When I move the "fixed" table rows to the bottom, the ListView will push them off the screen once it grows to a point where it should scroll. The ListView will only then begin to scroll when there is nothing else left that can be pushed off the screen:

Scrollable Android ListView in TableView Row

(source: heeroz.com)

How can I change my layout so that the table rows with the button and the EditText view remain visible?


Is there a particular reason you're using a TableLayout instead of a LinearLayout with android:orientation="vertical"? If you use the LinearLayout you can specify android:layout_weight="1" on the ListView and you should get the results you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜