Search code examples
androidtouch-eventgesturedetector

Android SimpleOnScaleGestureListener combined with OnDoubleTapListener


How can I combine SimpleOnScaleGestureListener and OnDoubleTapListener? If I do this in my onTouchEvent method:

if (!scaleGestureDetector.onTouchEvent(ev)) {
    doubleTabGestureDetector.onTouchEvent(ev);
}

My app will never catch a double tap.

How can I solve this? If I do both:

scaleGestureDetector.onTouchEvent(ev)
doubleTabGestureDetector.onTouchEvent(ev)

My app will interpret a scale gesture as a scale gesture but it will also interpret the same gesture as the first tab of a double tab gesture. I don't want that. I do not want the scale gesture to be handled by the doubleTabDetector at the same time.


Solution

  • Solution is to do it the other way around.

    if (!doubleTabGestureDetector.onTouchEvent(ev)) { scaleGestureDetector.onTouchEvent(ev); }

    and return false in the onDown of the doubleTabGestureListener.