2011-05-23 51 views
0

嘿,我正在嘗試爲我的活動創建一個佈局,但我無法在屏幕底部創建一個靜態按鈕,它不會隱藏列表查看最後的項目。 我看到很多方法,但他們都隱藏我的列表視圖的最後一項。 我想過使用「體重」參數,但它看起來不太好。 我試圖做的活動是在她的上面有一個圖像視圖,在圖像視圖下方出現的是非靜態的列表,底部假設是一個靜態按鈕,不會超出列表視圖。這是我寫的xml,但正如你所看到的,如果你試圖「運行」它(只是在表格佈局中添加一些東西),那麼如果列表很長,它將隱藏在按鈕下面。 PS:我正在建立列表視圖,所以現在它是一個表格佈局。在列表視圖的底部製作一個靜態按鈕

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="fill_parent" android:layout_width="fill_parent" 
     android:background="@drawable/background"> 

    <ImageView android:src="@drawable/search_title" 
     android:layout_alignParentTop="true" android:layout_height="wrap_content" 
     android:layout_width="wrap_content" android:paddingTop="10dip" 
     android:layout_gravity="center" android:id="@+id/shop_list_title" /> 

    <ScrollView android:layout_marginBottom="1dip" 
     android:layout_height="wrap_content" android:layout_width="fill_parent" 
     android:layout_below="@id/shop_list_title"> 
     <TableLayout android:id="@+id/shop_list_list" 
      android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     </TableLayout> 
    </ScrollView> 

    <Button android:id="@+id/shop_list_search_button" android:layout_alignParentBottom="true" 
     android:layout_height="wrap_content" android:layout_width="fill_parent" 
     android:text="@string/search_button_shoplist" /> 
</RelativeLayout> 

在此先感謝,Elad!

回答

2

我會建議在你的情況下使用LinearLayout

這裏是一個例子。我刪除了所有嘈雜的東西,只留下相關的屬性:

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

    <ImageView    
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" /> 

    <ScrollView  
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:fillViewport="true" > 

     <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
     </TableLayout> 

    </ScrollView> 

    <Button 
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content" /> 

</LinearLayout> 
+0

偉大的想法,沒有想過它。謝謝! – Elad92 2011-05-24 08:59:52