2011-02-10 74 views
0

該按鈕被隱藏...爲什麼?爲什麼我的按鈕隱藏?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="15dp" 
    android:orientation="vertical"> 
    <ListView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/feed_list"/> 
    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="More" 
     android:id="@+id/feed_more"/> 
</LinearLayout> 

回答

6

假設ListView有足夠的內容來填滿整個屏幕,它會因爲你告訴它wrap_content。您可以使用加權指示ListView佔用儘可能多的屏幕作爲可用時,按鈕有什麼後,它需要:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="15dp" 
android:orientation="vertical"> 
<ListView 
    android:layout_width="fill_parent" 
    android:layout_height="0" 
    android:weight="1" 
    android:id="@+id/feed_list"/> 
<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:weight="0" 
    android:text="More" 
    android:id="@+id/feed_more"/> 
1

你需要給重1到列表視圖。那麼你的按鈕將是可見的。嘗試一下。