【发布时间】:2016-06-06 14:13:47
【问题描述】:
在子对象中,我们需要跟踪坐标(ACTION_MOVE)。如果坐标为getX() > x,则必须向父对象发送事件。
问题:要将事件发送给父级我们需要返回false,但是如果返回false,我们将无法跟踪对象在子级中的坐标。
public boolean onTouch(View v,MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_MOVE) {
if (e.getY() > 200) {
return false; //we must send event to the parent object, but since then the ACTION_MOVE event no longer occurs here
} else {
myView.setTranslationY(e.getY());
return true; //we have to handle the event here
}
}
return false;
}
我该怎么做才能正确处理这两种情况?
【问题讨论】: