在Android布局中固定页脚

时间:2016-09-21 06:31:56

标签: android android-layout android-fragments footer

这是我的固定页脚布局。包含Fragment的{​​{1}}附加到RecyclerView。但FrameLayout的内容与页脚布局重叠。

RecyclerView

2 个答案:

答案 0 :(得分:2)

FrameLayout给予财产

android:layout_above="@+id/footer_linearlayout"

它会同时显示FrameLayoutFooter

以这种方式添加:

<FrameLayout
    android:id="@+id/home_parent_framelayout"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_above="@+id/footer_linearlayout" />

说明:

您的LinearLayout无法显示Bottom每当您创建修复页脚时,您的父项Layout您必须将layout_above属性赋予修复页脚的高度在您的情况下LinearLayout。高度以便在屏幕中显示LinearLayout您必须提供的父FrameLayout {。}}

答案 1 :(得分:1)

试试这个:

<?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">

    <FrameLayout
        android:id="@+id/home_parent_framelayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_above="@+id/footer_linearlayout" />

    <LinearLayout
        android:id="@+id/footer_linearlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#f1c21e"
        android:orientation="horizontal">

//Your footer layout
    </LinearLayout>

</RelativeLayout>