下拉几次后,下拉动画失效同时下拉回调也无反应
- 是不是手势被消费或者上层的图层覆盖导致的?(并不是)
- 是不是哪里调用了setEable = false ?(并不是)
- 是否是下拉控件bug ?(查看源代码后猜测是拦截未成功)
场景:SwipeRefreshLayout(v4) 和 RecyclerView(V7)
排查:排除手势和关闭刷新、最后就是下拉刷新控件和列表控件问题
源码查看
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
//省略部分代码
if (this.isEnabled() && !this.mReturningToStart && !this.canChildScrollUp() && !this.mRefreshing
&& !this.mNestedScrollInProgress) {
//省略部分代码
return this.mIsBeingDragged;
} else {
return false;
}
关注 canChildScrollUp()
这个方法
public boolean canChildScrollUp() {
if (this.mChildScrollUpCallback != null) {
return this.mChildScrollUpCallback.canChildScrollUp(this, this.mTarget);
} else {
return this.mTarget instanceof ListView ? ListViewCompat.canScrollList((ListView)this.mTarget, -1)
: this.mTarget.canScrollVertically(-1);
}
}
一顿百度 canChildScrollUp()
后查找到该文章
导致原因:
主要是适配器中的第一个数据的View,就
设置为不可见
GONE
所导致的原因,而当前可见的View下标索引是1,所以一直都不能让canChildScrollUp()
正常判断使用,我注释完立马烧一下代码,果真是这里的原因。

网友评论