协调器布局内的Recyclerview不滚动

时间:2018-05-28 16:22:28

标签: android android-recyclerview android-coordinatorlayout

我有以下活动

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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:id="@+id/coordinator">

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    android:id="@+id/catalog_view">

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginTop="79dp"
        android:background="@color/gray238"
        android:id="@+id/top_separator"/>

    ..

</android.support.constraint.ConstraintLayout>

    <include layout="@layout/check_view_sheet"/>

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

check_view_sheet

    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/check_bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="500dp"
    android:background="@color/colorWhite"
    android:orientation="vertical"
    app:behavior_hideable="false"
    app:behavior_peekHeight="80dp"
       app:layout_behavior="android.support.design.widget.BottomSheetBehavior">


    <FrameLayout
         app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
        android:layout_width="400dp"
        android:layout_height="235dp"
        android:id="@+id/catalog_view_check_fragment"
        />

    <TotalView.TotalView
        android:layout_width="match_parent"
        android:layout_height="@dimen/totalViewHeight"
        android:id="@+id/catalog_total_view" />

</LinearLayout>

在framelayout中查看

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

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/check_recycler_view"
        android:paddingBottom="@dimen/checkBottomPadding"
        android:clipToPadding="false"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

    </android.support.v7.widget.RecyclerView>

</android.support.constraint.ConstraintLayout>

问题是回收者视图不滚动。

我尝试在framelayout中包装nestedScrollView,但滚动的效果非常糟糕 - 它非常滞后,当我尝试滚动回收器视图时,它会隐藏工作表。

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

因为您尝试进行嵌套滚动,所以底部工作表具有可滚动的行为。

在RecyclerView

中试试
android:nestedScrollingEnabled="true"

如果在底页中滚动它确实是强制性的,否则请尝试将其设置为“false”。