2012-05-14 32 views
1

以下是我的視圖的XML。 (我只加了結構)。問題是當我在列表視圖(動態生成)中有幾個元素時,輸出將顯示直到最後一個按鈕的所有內容。但是一旦視圖在listview之後越過屏幕大小的元素不顯示。但是列表視圖中的所有元素都會出現。如何解決它改變這個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 s推出屏幕。

我建議你給它的高度fill_parent並玩layout_weight PARAMS。

有關進一步的參考,我會建議你閱讀this article有關使用RelativeLayout調整ListView與其他ViewViewGroup

相關問題