0

我的按鈕設置爲需要的大小(wrap_content);它確實有一個標題,但它是不可見的。它應該正好在我的ListView下方,我會認爲:爲什麼我的按鈕不被顯示?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ListView 
     android:id="@+android:id/listviewContacts" 
     android:layout_width="match_parent" 
     android:layout_height="300dip" 
     android:scrollbars="vertical | horizontal" > 
    </ListView> 

    <Button 
     android:id="@+id/buttonSaveAndBegin" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/save_settings_and_begin_responding" /> 

</LinearLayout> 

爲什麼我的按鈕不被顯示?

回答

4

LinearLayout的默認方向是水平的。如果您將android:orientation =「vertical」添加到LinearLayout,那麼您應該全部設置。

+1

很好的方向。 – 2012-02-06 01:46:33

2

可能是因爲300dip高度高於屏幕高度?

嘗試降低這個,看看你能看出來

+0

不,我可以看到ListView的大綱覆蓋了大約2/3的表單。 – 2012-02-05 22:38:55

1

嘗試改變:

android:layout_height="300dip" 

要這樣:

android:layout_height="match_parent" 

這是最有可能是大小的問題,而這將確保您的視圖是屏幕的確切大小。

+0

如果我的列表中有一個gazillion項目,該怎麼辦?如果我沒有指定高度,ListView是否會一直延伸到澳大利亞,甚至塔斯馬尼亞? – 2012-02-05 22:40:20

+0

它會和父母一樣大......點是它是一個測試..不是解決方案。 – 2012-02-06 01:46:07

3

在您的線性佈局這樣

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_height="match_parent" > 

添加垂直始發和你不需要垂直滾動視圖屬性添加到列表視圖列表視圖...帶着默認的垂直滾動視圖

1

嘗試使用ListView頁腳添加按鈕。

相關問題