我在我的布局中实现了一个持久的 Bottom Sheet - 一个无法完全隐藏但总是从底部看到的工作表。 但它覆盖了最后一个 RecyclerView 项目。 如何设置布局,使窥视不会隐藏最后一项?
截图:-
<?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>
最佳答案
这很愚蠢。问题发布后我自己就知道了解决方案。 :) 只需要向 RecyclerView 添加 android:paddingBottom 属性即可。
<android.support.v7.widget.RecyclerView
android:id="@+id/studentListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"/>
关于android-layout - 持续查看 Bottom Sheet 单,覆盖最后一个 RecyclerView 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56142643/