Android [TouchEvent]触摸事件溢出
代码fist:Android [TouchEvent]触摸事件溢出,android,touch-event,Android,Touch Event,代码fist: @Override public boolean onInterceptTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: isActionCancel = false; isTouchOrRunning = true; lastY = ev.getY();
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
isActionCancel = false;
isTouchOrRunning = true;
lastY = ev.getY();
break;
}
return super.onInterceptTouchEvent(ev);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (oa != null && oa.isRunning()) {
ev.setAction(MotionEvent.ACTION_UP);
isActionCancel = true;
}
if (isActionCancel && ev.getAction() != MotionEvent.ACTION_DOWN) {
return false;
}
if (ev.getActionIndex() != 0 && getScrollY() < range) {
ev.setAction(MotionEvent.ACTION_UP);
isActionCancel = true;
}
switch (ev.getAction()) {
case MotionEvent.ACTION_MOVE:
isTouchOrRunning = true;
if (getScrollY() != 0) {
detalY = 0;
lastY = ev.getY();
} else {
detalY = ev.getY() - lastY;
if (detalY > 0) {
setT((int) -detalY / 5);
return true;
}
}
break;
case MotionEvent.ACTION_UP:
isTouchOrRunning = false;
if (getScrollY() < range) {
if (detalY != 0) {
reset();
} else {
toggle();
}
return true;
}
break;
}
return super.onTouchEvent(ev);
}
@覆盖
公共布尔值onInterceptTouchEvent(MotionEvent ev){
开关(ev.getAction()){
case MotionEvent.ACTION\u DOWN:
isActionCancel=false;
isTouchOrRunning=真;
lastY=ev.getY();
打破
}
返回超级onInterceptTouchEvent(ev);
}
@凌驾
公共事件(MotionEvent ev){
if(oa!=null&&oa.isRunning()){
ev.设置动作(MotionEvent.动作启动);
isActionCancel=true;
}
if(isActionCancel&&ev.getAction()!=MotionEvent.ACTION\u DOWN){
返回false;
}
如果(ev.getActionIndex()!=0&&getScrollY()0){
setT((int)-detalY/5);
返回true;
}
}
打破
case MotionEvent.ACTION\u UP:
ISTOUCHORRUNING=假;
if(getScrollY()<范围){
如果(详细情况!=0){
重置();
}否则{
切换();
}
返回true;
}
打破
}
返回super.onTouchEvent(ev);
}
正如我所知,视图必须使用ACTION\u DOWN事件才能接收其他eventaction,但是在上面的代码中,在onTouchEvent()函数中ACTION\u DOWN没有在那里处理,这个视图如何在onInterceptTouchEvent上接收ACTION\u MOVE和ACTION\u UP???
返回true
?@Hugo Gresse return super.onInterceptTouchEvent(ev);哪个默认值为false。我是说您应该在InterceptTouchEvent上返回true,以便在onTouchEvent中捕获它