Android 使用列表视图在屏幕底部制作静态按钮

Android 使用列表视图在屏幕底部制作静态按钮,android,android-layout,android-listview,Android,Android Layout,Android Listview,嘿,我正在尝试为我的活动创建一个布局,但是我不能在屏幕底部创建一个静态按钮,这不会隐藏列表视图最后的项目。 我看到了很多方法,但它们都隐藏了列表视图的最后一项。 我考虑过使用“权重”参数,但它看起来不太好。 我试图制作的活动在其顶部有一个图像视图,在图像视图下面是列表,它不是静态的,在底部假设是一个静态按钮,它不会超过列表视图。这是我编写的xml,但正如您所看到的,如果您尝试“运行”它(只需在表布局中添加一些内容),那么如果列表很长,则会隐藏在按钮下。 PS:我正在构建列表视图,所以现在它是一个

嘿,我正在尝试为我的活动创建一个布局,但是我不能在屏幕底部创建一个静态按钮,这不会隐藏列表视图最后的项目。 我看到了很多方法,但它们都隐藏了列表视图的最后一项。 我考虑过使用“权重”参数,但它看起来不太好。 我试图制作的活动在其顶部有一个图像视图,在图像视图下面是列表,它不是静态的,在底部假设是一个静态按钮,它不会超过列表视图。这是我编写的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>


提前谢谢你,埃拉德

我建议在您的情况下使用
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>

好主意,没想过。谢谢