1

Possible Duplicate:
How to implement doubletap on imageview’s onclick?

In my application I have a Relative layout with three image views.

In the activity I have implemented the simplegesturelistener for getting the swipe to work. Because of this i had to override the onDoubleTap method as well.

My problem is that I want to use the double tap event to zoom out the image from the image view on which the double tap happened (Need to recognize one of the three image views on the layout).

Is there a way to achieve this in the current scenario?

Community
  • 1
  • 1
Anuj
  • 389
  • 1
  • 5
  • 20
  • http://iotasol.wordpress.com/2011/08/09/zoom-image-on-double-tap-in-android/ – Raghunandan Oct 25 '12 at 12:48
  • http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/. This should help you. – Raghunandan Oct 25 '12 at 12:51
  • I dont think you guys read the question closely enough. My problem is not about achieving zooming out of image view. My problem is identifying one out of the tree imageviews on which the double tap happened. – Anuj Oct 25 '12 at 12:53

1 Answers1

0

You can refer below code

        gestureDetector = new GestureDetector(new MyGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };

Here I have used Gesture for swipe functionality, and I also have webview in layout in which swipe should work. So webview's scroll and swipe both should work i have added below methods. Mainly this method is important to add dispatchTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {

    return (gestureDetector.onTouchEvent(event) || super
            .onTouchEvent(event));
}

@Override
public boolean dispatchTouchEvent(MotionEvent e) {
    super.dispatchTouchEvent(e);
    return gestureDetector.onTouchEvent(e);
}
Nirali
  • 13,571
  • 6
  • 40
  • 53
  • I am not sure i fully understood the relationship between your answer and the problem statement. – Anuj Oct 25 '12 at 13:07