【问题标题】:Fixed footer in android layout修复了 android 布局中的页脚
【发布时间】:2017-01-29 06:11:48
【问题描述】:

这是我的固定页脚布局。包含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>

【问题讨论】:

    标签: android android-layout android-fragments footer


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

      在你的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..

      【讨论】:

      • framelayout 具有高度作为包装内容,因此当我添加 android:layout_above="@+id/footer_linearlayout" 时,framelayout 布局显示在页脚上方,但在其上方留下了很多空白空间(framelayout)有高度环绕内容。
      • 然后将FrameLayout 高度指定给match_parent,它将占用完整高度到FrameLayout。它会解决你的问题..
      • @Androidjack 很高兴为您提供帮助。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-16
      • 2021-08-09
      • 1970-01-01
      • 2012-01-19
      • 2019-09-10
      相关资源
      最近更新 更多