Android View Event dispatch

There are three mainly methods in event dispatch

public boolean dispatchTochEvent(MotionEvent ev) dispatch event the return value mean if consume this event

public boolean onInterceptTouchEvent(MotionEvent event) show if this view intercept this event, if true, this method not invoke again.

public boolean onTouchEvent(MotionEvent event) use to handle event, if return false, this view not receive this series of event again.

below code show the relationship of these three method

In the end of this link is onTouchEvent, in side, if we have set onClickListener, it will be invoke, onClickListener is the last priority.

The order of events dispatch

When click event generate the dispatch order is ACTIVITY->WINDOW->View

In this order, event will arrived to bottom view, if this view can’t handle, the event will give to parent view, and so on.

u3coding
A software developer

Leave a Comment

Your email address will not be published. Required fields are marked *

*