zhou-you / EasyXRecyclerView

主要提供了简单易用强大的RecyclerView库,包括自定义刷新加载效果、极简通用的万能适配器Adapter、万能分割线、多种分组效果、常见状态页面、item动画效果、添加多个header和footer、侧滑、拖拽、Sticky(黏性)效果、多item布局等,各模块之间灵活、解耦、通用、又能相互组合使用。
628 stars 116 forks source link

CoordinatorLayout中如果使用了CollapsingToolbarLayout会出现滑动问题 #1

Closed klaokai closed 5 years ago

klaokai commented 6 years ago

机型:I999 版本:Android 4.2

布局代码

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="192dp"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
            app:layout_scrollInterpolator="@android:anim/decelerate_interpolator"
            app:toolbarId="@+id/toolbar">

            <ImageView
                android:id="@+id/app_bar_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@android:drawable/sym_def_app_icon" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <com.zhouyou.recyclerview.XRecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never"
        android:fitsSystemWindows="true"
        app:layoutManager="android.support.v7.widget.LinearLayoutManager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:clickable="true"
        android:src="@android:drawable/ic_input_add" />
</android.support.design.widget.CoordinatorLayout>)

表现: 下拉XRecyclerView时,Toolbar无法展开,XRecyclerView不停地跳跃回弹,无法带动CollapsingToolbarLayout展开。

应该是app:layout_behavior="@string/appbar_scrolling_view_behavior"指定的behavior不能适配这个XRecyclerView。

建议: 可以继承AppBarLayout.ScrollingViewBehavior来解决这一问题,并使用@CoordinatorLayout.DefaultBehavior(myScrollingViewBehavior.class)来标记XRecyclerView

tarooo commented 6 years ago

我也遇到这歌问题,下拉刷新的时候卡顿一下,怎么解决,上面那个建议能具体点吗

klaokai commented 6 years ago

@tarooo 我暂时按照demo给的方式处理,我说的那种解决方式需要写一个额外的类myScrollingViewBehavior来解决这个适配问题。不过这种解决方式会有Android版本的要求。作者有可能考虑到这一问题暂时没有加入。