scwang90 / SmartRefreshLayout

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
https://segmentfault.com/a/1190000010066071
Apache License 2.0
24.79k stars 4.93k forks source link

Activity滑动卡顿 #1537

Open 15239545925 opened 10 months ago

15239545925 commented 10 months ago

为什么在Activity里面使用SmartRefreshLayout嵌套RecyclerView。下拉刷新的时候会卡顿,下拉不了,只能先网上再往下才会触发下拉刷新。以下是我的代码布局设置 <com.scwang.smart.refresh.layout.SmartRefreshLayout android:id="@+id/refreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:srlEnableOverScrollBounce="false" app:srlEnableOverScrollDrag="false">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recycler"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:overScrollMode="never"
                    android:scrollbars="none"
                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    tools:itemCount="8"
                    tools:listitem="@layout/item_task_list" />

            </com.scwang.smart.refresh.layout.SmartRefreshLayout>

全局参数设置: SmartRefreshLayout.setDefaultRefreshInitializer((context, layout) -> { //全局设置(优先级最低) layout.setEnableAutoLoadMore(false); layout.setEnableOverScrollDrag(false); layout.setEnableOverScrollBounce(false); layout.setDisableContentWhenLoading(false); layout.setDisableContentWhenRefresh(false); layout.setEnableLoadMoreWhenContentNotFull(false); layout.setEnableFooterFollowWhenNoMoreData(true); layout.setEnableScrollContentWhenRefreshed(true); layout.setEnableScrollContentWhenLoaded(true); layout.setEnableFooterTranslationContent(true); layout.setEnableHeaderTranslationContent(true); layout.setPrimaryColorsId(R.color.colorTransparent, R.color.color666666, R.color.colorTransparent); layout.setDragRate(.7f).setReboundDuration(500).setHeaderMaxDragRate(4.0f) .setHeaderHeight(50).setFooterMaxDragRate(4.0F).setFooterHeight(45); }); SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) -> new ClassicsHeader(context).setTimeFormat(new DynamicTimeFormat("更新于 %s"))); SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) -> new ClassicsFooter(context));