Alex Rivera | Logout

Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?

Asked 2012-03-06T14:52:50.657
279

What is the difference between onInterceptTouchEvent and dispatchTouchEvent in Android?

According to the android developer guide, both methods can be used to intercept a touch event (MotionEvent), but what is the difference?

How do onInterceptTouchEvent, dispatchTouchEvent and onTouchEvent interact together within a hierarchy of Views (ViewGroup)?

Edit
Report

1 Answer

2

The main difference :

•Activity.dispatchTouchEvent(MotionEvent) - This allows your Activity to intercept all touch events before they are dispatched to the window.
•ViewGroup.onInterceptTouchEvent(MotionEvent) - This allows a ViewGroup to watch events as they are dispatched to child Views.

answered 2012-03-06T14:59:30.590

Your Answer