2011-05-23 37 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

相关问题