I have a custom ZoomableViewGroup that overrides onTouchEvent to handle pan/fling movements, and uses ScaleGestureDetector.SimpleOnScaleGestureListener to handle zoom gestures. This ZoomableViewGroup works fine until I try to use onTouch in children of the ViewGroup.
Inside this ZoomableViewGroup I have multiple ImageViews that serve as buttons. I would like the functionality of the parent to take precedent over the onTouch of the children. As it stands it seems the child ImageViews are intercepting touchevents and not passing them to it's parent.
I would like to know what a good method of ensuring that a parent's touch functionality is preserved over it's children's touch functionality.
Any help or suggestions would be greatly appreciated!
EDIT:
Your response has been extremely helpful Jason, I think i'm starting to make sense of this situation better now. I've been messing around with my zoomable view groups onInterceptTouchEvent method, but am still a bit confused
how is my ImageView supposed to get the relevant ACTION_UP info if it's aleady recieved an ACTION_CANCEL from it's parent ViewGroup?
please correct me if I'm interpreting what's happening wrong here too! Thanks Again!
The basic idea is to override onInterceptTouch
in the parent view and provide logic there for whether or not to pass on the touch to the child view (return false
) or to actually allow the parent view to intercept/consume the touch (return true
). Your logic can be spatial (perhaps the edges of the parent view are special, but not the interior), or gestural (perhaps horizontal swipes trigger something at the parent view level and vertical swipes trigger something at the child view level, or, in your case, simple taps get passed to the child buttons, but two finger gestures get consumed by the parent).