首页 > 学院 > 开发设计 > 正文

SwipeRefreshLayout+RecyclerView滑动冲突解决

2019-11-08 00:02:22
字体:
来源:转载
供稿:网友

本文出自:http://blog.csdn.net/dt235201314/article/details/56844047

一丶概述

最近处于改bug阶段,bug自然就多了

SwipeRefreshLayout和RecyclerView一起使用会造成下拉刷新在上拉之后,轻易下拉就会刷新的bug

二丶解决方法

一个方法便能解决:

public void setSwipeRefreshLayout(SwipeRefreshLayout swipeRefreshLayout) {    swipeRefreshLayout.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() {        @Override        public boolean canChildScrollUp(SwipeRefreshLayout parent, @Nullable View child) {            if (mRecyclerView == null) {                return false;            }            LinearLayoutManager linearLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();            return linearLayoutManager.findFirstCompletelyVisibleItemPosition() != 0;        }    });}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表