Closed yongchao1210 closed 8 years ago
CustScrollView不能作为底部容器的。底部Fragment的touch分发和拦截可参考CustWebView
那如果底部容器需要用到ScrollView 需要在吗处理?工程里的CustScrollView是做什么用的?谢谢
如果底部容器用到ScrollView当然可以了。你看一下CustWebView的实现方式,你模仿一下就好了。Touch的分发和拦截,可以一模一样的。
好的,感谢!
CustScrollView 类没有什么作用可以删除是吧
量体裁衣,如果你顶部不是ScrollView,可以删掉的
哦,明白了 ,谢谢
我改了下CustScrollView的实现方式,想让底部的view支持scrollview,但是滚动的时候感觉不流畅, Logcat信息是Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream. 下面是我改的代码
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
upY = ev.getRawY();
needConsumeTouch = true; // 默认情况下,scrollView内部的滚动优先,默认情况下由该ScrollView去消费touch事件
} else if (ev.getAction() == MotionEvent.ACTION_UP) {
upY = ev.getRawY();
needConsumeTouch = true; // 默认情况下,scrollView内部的滚动优先,默认情况下由该ScrollView去消费touch事件
if (getScrollY() <= 2) {
// 允许向上拖动至顶部上一页
allowDragUp = true;
} else {
// 不允许向上拖动至顶部上一页
allowDragUp = false;
}
} else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
if (!needConsumeTouch) {
// 在最顶端且向上拉了,则这个touch事件交给父类去处理
getParent().requestDisallowInterceptTouchEvent(false);
return false;
} else if (allowDragUp) {
// needConsumeTouch尚未被定性,此处给其定性
// 允许拖动到至顶部上一页,而且又向上拖动了,就将touch事件交给父view
if (upY - ev.getRawY() < 2) {
// flag设置,由父类去消费
needConsumeTouch = false;
getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
}
}
// 通知父view是否要处理touch事件
getParent().requestDisallowInterceptTouchEvent(needConsumeTouch);
return super.dispatchTouchEvent(ev);
}
不是custscrollview的问题,是你改了draglayout
把 CustScrollView 作为底组件时候,拉动到底部页面时候,无法拉动回到顶部页面