Question

I have a little (100*100) View, that I added to WindowManager, and I want it to intercept all the touch events, including that are outside of this view. By default, touch outside this view is handled by view "behind" this view.

Was it helpful?

Solution

Use Activity's method dispatchTouchEvent

Called to process touch screen events. You can override this to intercept all touch screen events before they are dispatched to the window. Be sure to call this implementation for touch screen events that should be handled normally.

This code will let your little view intercept all touch events.

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    return littleView.onTouchEvent(ev);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top