如何固定最后一个页脚(ListView)

How to make the last footer fixed (ListView)

我有一个 ListView 有 2 个页脚视图。第一个是一堆TextView,第二个是一个按钮。我正在尝试修复第二个页脚,使其始终显示在屏幕底部。

我尝试了以下方法:

1.  alignParentBottom = true

2.  layout_gravity="bottom"

3.  footerView2.bringToFront()

以及上述的组合。但其中 none 成功了。我怎样才能做到这一点?

更新

我不应该添加我一直想要在屏幕上(固定)作为页脚的 View

我刚刚添加了 wannabe-fixed-view 和 listView。 alignParentBottom = trueview.bringToFront()。它对我有用。

创建单独的 xml 文件,其中包含您想要作为页脚的所有文本视图和按钮 part.Then 将此 xml 绑定为列表视图的页脚。您可以通过以下方法将页脚与列表视图合并:listview.addFooterView(footerView);
例如:

View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.listviewfooter, null, false);
        spDate = (Spinner) headerView.findViewById(R.id.spdate);
        llDatepicker = (LinearLayout) headerView.findViewById(R.id.lldatepicker);
        rvDatepicker = (RecyclerView) headerView.findViewById(R.id.rvdatepicker);
        rvTimepicker = (RecyclerView) headerView.findViewById(R.id.rvtimepicker);

              lvAddress.addFooterView(footerView);

ListView 和底部页脚分开。思路是:

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

    <Button
        android:id="@+id/btn_bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Bottom button"/>

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/btn_bottom"/>

</RelativeLayout>
If you are Trying to add a View which will be shown even if we scroll the List Up or Down... u can do something like this. I had done this before But as a header.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:id="@+id/new_container"
    android:background="@color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="LOAD EARLIER MESSAGES"
        android:id="@+id/loadMore"
        android:background="#90F58220"
        android:visibility="visible"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listContainer"
        android:layout_below="@+id/loadMore"
        android:layout_above="@+id/container">
        <ListView
            android:id="@+id/messagesContainer"
            android:transcriptMode="normal"
            android:dividerHeight="0dp"
            android:divider="@null"
            android:stackFromBottom="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

       </RelativeLayout>
<RelativeLayout
        android:id="@+id/container"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:background="#ffffff"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:paddingLeft="0dp"
        android:paddingRight="0dp"
        android:layout_height="wrap_content" >
    </RelativeLayout>

The LoadMore Button is always visible on the Top of the List...
To add it to footer, Just Change

    android:layout_below="@+id/loadMore"
    android:layout_above="@+id/container"

to

    android:layout_above="@+id/loadMore"