首页 > 解决方案 > 覆盖最后一个 RecyclerView 项目的持久底部表偷看

问题描述

我在我的布局中实现了一个持久的底页——它不能完全隐藏,但总是从底部偷看。 但它涵盖了最后一个 RecyclerView 项目。 如何设置布局以使 peek 不会隐藏最后一项?

截屏:-

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

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recylerView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_weight="1" />
            </RelativeLayout>
        </android.support.v4.widget.NestedScrollView>

        <!-- Buttom Sheet -->
        <android.support.v7.widget.LinearLayoutCompat
            android:id="@+id/bottom_sheet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:orientation="vertical"
            app:behavior_hideable="true"
            app:behavior_peekHeight="56dp"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:layout_gravity="center_vertical"
                android:background="@android:color/holo_green_dark"
                android:orientation="horizontal"
                android:padding="10dp"
                android:weightSum="3">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="10dp"
                    android:layout_weight="2"
                    android:text="Submit Report"/>

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="right"
                    android:text="8/10"/>
            </LinearLayout>
            <!-- Other things to add -->
        </android.support.v7.widget.LinearLayoutCompat>

    </android.support.design.widget.CoordinatorLayout>
</FrameLayout>

标签: android-layoutandroid-coordinatorlayoutandroid-design-librarybottom-sheet

解决方案


这很愚蠢。发布问题后,我自己就知道了解决方案。:) 只需将android:paddingBottom属性添加到 RecyclerView。

<android.support.v7.widget.RecyclerView
                    android:id="@+id/studentListView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="56dp"/>

推荐阅读