2012-05-14 18 views
1

以下は私のXMLです。 (私は構造体を追加しただけです)。問題は、リストビューに(動的に生成された)いくつかの要素がある場合、出力に最後のボタンまですべてが表示されることです。しかし、いったんリストビューが表示されないと、画面サイズの要素を過ぎるとビューが大きくなります。リストビューのすべての要素が表示されます。このXMLを変更しないように修正する方法AndroidでListViewの後に要素を追加する方法

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TableRow > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    </TableRow> 
</TableLayout> 
<ListView 
    android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
</ListView> 
<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TableRow > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    </TableRow> 
</TableLayout> 
<Button 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" /> 
<Button 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent"/> 
</LinearLayout> 
+1

[この複製](http://stackoverflow.com/questions/2383847/android-layout-with-listview-and-buttons) – keyser

答えて

4

ListViewは高さが空いています。 ListViewを提示する最悪の場合は、それにwrap_contentの高さを与えることです。

ListViewのアイテムが大きくなると、ListViewはコンテンツをラップするために高さが上がり、その結果、他のViewが画面外に押し出されます。

高さをfill_parentにして、layout_weight paramsで遊んでみることをお勧めします。

さらに参考のために、私はあなたが他のViewViewGroupListViewを調整するRelativeLayoutの使用についてthis articleを読むことをお勧めします。

関連する問題