Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Two finger double tap possible to detect with GestureDetector?

question above. For me getPointerCount() is always 1, once a double tap is detected.

 private GestureDetector mGestureDetector;
 mGestureDetector = new GestureDetector(this, new MyGestureListener());    

...

 public boolean onTouch(View v, MotionEvent event) {
     return mGestureDetector.onTouchEvent(event);
 }  

...

private class MyGestureListener extends  GestureDetector.SimpleOnGestureListener {

    @Override
    public boolean onDoubleTap(MotionEvent e) {
         return super.onDoubleTap(e);
    } 

}
like image 307
decades Avatar asked Apr 14 '11 11:04

decades


People also ask

What is touch gestures in Android?

Android provides special types of touch screen events such as pinch , double tap, scrolls , long presses and flinch. These are all known as gestures. Android provides GestureDetector class to receive motion events and tell us that these events correspond to gestures or not.

In what way gestures are preferred than touch events?

 Gestures are scripted “solutions” that take advantage of these touch events.  So instead of tracking two touch points to determine if they're moving away or closer to one another in order to manipulate the size of a photo, you can just use GESTURE_ZOOM.


1 Answers

The GestureDetector is only capable of detecting "one finger" gestures. The "double tap" gesture you are currently listening to, occurs when the user tapped, released and tapped again the screen with one of his/her fingers.

If you want to listen to gestures with multiple fingers you'll have to do it on your own or use the ScaleGestureDetector (only for the scale gesture).

like image 116
Cyril Mottier Avatar answered Oct 20 '22 10:10

Cyril Mottier