Search code examples
androideventstouchviewgroup

After intercepting a touch event, how to give it back to a child?


I have a custom FrameLayout which overrides this method:

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_MOVE:
            return interceptTouchEvents;
    }

    return false;
}

I then have a touch listener which I set as the TouchListener of this FrameLayout. At some point inside the onTouch method I'd like to forward this event to a children.


Solution

  • you can use below code for dispatch touch event to view, // Dispatch touch event to view

    view.dispatchTouchEvent(motionEvent);
    

    Hope this will help.

    Thanks