Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does onInterceptTouchEvent() really works as the sdk said?

Tags:

android

ths sdk said:

3、For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().

4、If you return true from here, you will not receive any following events: the target view will receive the same event but with the action ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

But when i use this method,no matter what onInterceptTouchEvent() returns ,it does the same work! And never did MotionEvent.ACTION_MOVE or MotionEvent.ACTION_UP been captured by this method. Can anybody help me figure it out?

ths!

like image 896
i need to learn Avatar asked Jun 29 '11 10:06

i need to learn


1 Answers

Normally the touch goes from most upper view to the lowest through onInterceptTouchEvent and then it goes back via onTouchEvent.

If you return true in onInterceptTouchEvent you forbid it to continue and the view where you returned true is the last one to receive the touch, you consume it

You can also disallow your parent view to consume the event by requestDisallowInterceptTouchEvent(true);

like image 96
Lukas Hanacek Avatar answered Sep 28 '22 07:09

Lukas Hanacek