android 布局中的固定页脚
Fixed footer in android layout
这是我的固定页脚布局。包含 RecyclerView
的 Fragment
附加到 FrameLayout
。但是 RecyclerView
的内容被页脚布局覆盖了。
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<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" />
<LinearLayout
android:id="@+id/footer_linearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#f1c21e"
android:layout_alignParentBottom="true">
<footer layout>
</LinearLayout>
</RelativeLayout>
试试这个:
<?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>
在你的 FrameLayout
中给出 属性
android:layout_above="@+id/footer_linearlayout"
它将同时显示 FrameLayout
和 Footer
。
这样添加:
<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
属性 到Fix Footer 的高度在您的情况下意味着 LinearLayout
。高度以便在屏幕上显示 LinearLayout
父子 FrameLayout
你必须给 android:layout_above="@+id/linearLayout
..
这是我的固定页脚布局。包含 RecyclerView
的 Fragment
附加到 FrameLayout
。但是 RecyclerView
的内容被页脚布局覆盖了。
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<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" />
<LinearLayout
android:id="@+id/footer_linearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#f1c21e"
android:layout_alignParentBottom="true">
<footer layout>
</LinearLayout>
</RelativeLayout>
试试这个:
<?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>
在你的 FrameLayout
中给出 属性
android:layout_above="@+id/footer_linearlayout"
它将同时显示 FrameLayout
和 Footer
。
这样添加:
<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
属性 到Fix Footer 的高度在您的情况下意味着 LinearLayout
。高度以便在屏幕上显示 LinearLayout
父子 FrameLayout
你必须给 android:layout_above="@+id/linearLayout
..