private SwipeRefreshLayout mRefreshLayout;
private RecyclerView mRecyclerView;
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int topPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
mRefreshLayout.setEnabled(topPosition >= 0);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
});
Android下拉刷新SwipeRefreshLayout和列表RecyclerView滑动冲突的解决方法
原创yongfengnice 博主文章分类:android ©著作权
文章标签 android-widget ide 文章分类 Android 移动开发
上一篇:Android独立于Activity或者Fragment的LoadingDialog的实现
下一篇:Android配置文件gradle里的buildConfigField和manifestPlaceholders的理解
-
SwipeRefreshLayout 嵌套 RecyclerView滑动冲突
原则上你使用的RecyclerView框架可能是自带刷新的,如果没有就可能会出现这种问题,滑动时会出现卡顿、触发刷新的时机也不对。思路
滑动冲突 SwipeRefreshLayout 嵌套