QMUIContinuousNestedScrollLayout的dispatchTouchEvent方法中 在滑动状态IDLE之前对事件进行了拦截,但这个状态存在延迟的问题,就照成视觉上滑动已经停止了,但有短暂的时间内点击事件无法响应,看到有注释must stop scroll and not use the current down event,但不太明白为什么怎么做,尤其是在fling到顶部或底部,stopScroll后直接super.dispatchTouchEvent(down)释放down event会造成什么问题呢。
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if(mCurrentScrollState != IQMUIContinuousNestedScrollCommon.SCROLL_STATE_IDLE){
// must stop scroll and not use the current down event.
// this is worked when topView scroll to bottomView or bottomView scroll to topView.
stopScroll();
mIsDismissDownEvent = true;
mDismissDownY = ev.getY();
if(mTouchSlap < 0){
mTouchSlap = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
return true;
}
} else if(ev.getAction() == MotionEvent.ACTION_MOVE && mIsDismissDownEvent){
if(Math.abs(ev.getY() - mDismissDownY) > mTouchSlap){
MotionEvent down = MotionEvent.obtain(ev);
down.setAction(MotionEvent.ACTION_DOWN);
down.offsetLocation(0, mDismissDownY - ev.getY());
super.dispatchTouchEvent(down);
down.recycle();
}else{
return true;
}
}
mIsDismissDownEvent = false;
return super.dispatchTouchEvent(ev);
}
运行环境
一加 7t
Android 10
4.10.1
2.0.0-alpha11
具体问题描述
QMUIContinuousNestedScrollLayout
的dispatchTouchEvent
方法中 在滑动状态IDLE之前对事件进行了拦截,但这个状态存在延迟的问题,就照成视觉上滑动已经停止了,但有短暂的时间内点击事件无法响应,看到有注释must stop scroll and not use the current down event,但不太明白为什么怎么做,尤其是在fling到顶部或底部,stopScroll后直接super.dispatchTouchEvent(down)释放down event会造成什么问题呢。问题截图
可以使用demo QMUIContinuousNestedScrollLayout -> linearLayout + recyclerview fling到底部,然后点击item,一段时间内是没有响应的