【问题标题】:Recyclerview inside coordinator layout not scrolls协调器布局内的 Recyclerview 不滚动
【发布时间】:2018-11-07 06:42:18
【问题描述】:

我有以下活动

<?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>

在框架布局内查看

<?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 中,但滚动的性能很糟糕 - 它非常滞后,并且当我尝试向下滚动回收站视图时它会隐藏工作表。

如何解决这个问题?

【问题讨论】:

    标签: android android-recyclerview android-coordinatorlayout


    【解决方案1】:

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

    在 RecyclerView 中试试这个

    android:nestedScrollingEnabled="true"
    

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

    【讨论】:

    • 尝试在嵌套 Scoll 视图中添加视图
    • 我写过有问题的嵌套滚动视图
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    相关资源
    最近更新 更多