views:

88

answers:

1

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: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>      

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:

alt text

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:

alt text

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

+3  A: 

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.

Qberticus
I don't recall a particular reason, and I will try your suggestion. Thanks.
cdonner
Works better, and so far I have not discovered any disadvantages, . Thanks!
cdonner