相关疑难解决方法(0)

Android:如何对齐底部的按钮和上面的listview?

我想在列表视图的底部有一个按钮.

如果我使用relativeLayout/FrameLayout,它会对齐,但listView会变得非常紧张.

(在底部的按钮后面)

在此输入图像描述

的FrameLayout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/btnButton"
            android:text="Hello"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom" />
    </FrameLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

RelativeLayout的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/btnButton"
            android:text="Hello"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom" />
    </RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

以上两个代码只能像第一张图像一样工作.我想要的是第二张图片.

有人可以帮忙吗?

谢谢.

layout android listview alignment

74
推荐指数
1
解决办法
8万
查看次数

标签 统计

alignment ×1

android ×1

layout ×1

listview ×1