2011-11-22 29 views
0
 <?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="fill_parent" 
    android:orientation="vertical" 
    style="@style/listbag"> 
    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="1dp"> 
    <ListView 
     android:id="@+id/groupListView" 
     style="@style/listbag" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="100" 
     android:listSelector="@drawable/list_selector1" 
     android:background="@drawable/radius" /> 
</LinearLayout> 
<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="1dp"> 
    <Button 
     android:id="@+id/addfrendstogroupButton" 
     android:layout_width="fill_parent" 
     android:layout_height="42dp" 
     android:text="Create new group" 
     android:textColor="@color/gray2" 
     android:background="@drawable/button_indicator" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginBottom="1dp" 
     android:layout_alignParentBottom="true" 

     /> 
     </RelativeLayout> 

      </LinearLayout> 

我想設置列表視圖和在屏幕底部的一個按鈕。但是當我填充listView時,按鈕不再出現。我不知道爲什麼。有人可以幫我嗎?按鈕沒有出現在我的佈局

+0

「填充ListView」是什麼意思? – iTurki

回答

1

讓您的列表視圖和按鈕位於單個相對佈局。並給你的按鈕alignparentbottom的財產。即使您的列表視圖已滿並且需要滾動,該按鈕仍會始終位於列表的上方。

希望這會有所幫助。

0

讓您的佈局是這樣的:

<RelativeLayout> 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    <ListView> 
     .... 
    </ListView> 
    <Button 
     .... 
     android:layout_alignParentBottom="true" 
     .... /> 
</RelativeLayout> 
0

我想補充到@iturki,這將是更加靈活,像這樣做:

<RelativeLayout> 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

<Button 
    .... 
    android:id="@+id/button" 
    android:layout_alignParentBottom="true" 
    .... /> 
<ListView> 
    .... 
    android:above="@id/button" 
    .... 
</ListView> 
</RelativeLayout> 

否則Button會在ListView之上,因此隱藏了它的結尾。

+0

我認爲這就是我們想要的,因爲這個按鈕已經超過了列表的範圍。 – Urban

+0

SWhat我的意思是,與其他答案'按鈕'會隱藏'ListView'的末尾。 **更新** – pablisco