Reputation: 1358
For (single)touch gestures, there is a GestureOverlayView view which can be placed over other views (Gridviews, Listviews ... ) and empty space and still detect touch correctly.
/Edit: A little bit of more specification
Right now im doing this:
//setup listener
overlay = (GestureOverlayView) findViewById(R.id.CgestureOverlayView);
overlay.setGestureVisible(false);
overlay.addOnGesturePerformedListener(this);
But then when im using GestureOverlayView i have to implement this
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture)
problem is i don't have Raw gesture file because Gestures Builder does not allow me to build multitouch gestures. Where to implement mentioned MotionEvent handling?
Should i do something like this and then override GestureOverlayView.onTouchEvent() ? (Or i dont see your point because you can use OnTouchEvent even without GestureOverlayView)
public boolean onTouchEvent(MotionEvent ev) {
overlay.onTouchEvent(ev);
return true;
}
//Edit#2 Well in the end, i didn't had to use GestureOverlay, i caught those MouseEvents from ListView which fills the whole activity. Anyway when you have MotionEvents you dont have to define your own multitouch gestures, instead you can use ScaleGestureDetector.SimpleOnScaleGestureListener for processing such events.
Upvotes: 1
Views: 665
Reputation: 2566
GestureOverlayView lets you set a listener of type GestureOverlayView.OnGestureListener. The methods in this interface are passed the raw MotionEvents that the GestureOverlayView is receiving.
From these events it should be possible to detect any gesture required, even multitouch ones.
Edit: Instead of using
overlay.addOnGesturePerformedListener(this);
you would use
overlay.addOnGestureListener(this);
This would give you the raw MotionEvents that can be used to determine any multitouch gestures. From there you will need to do your own tracking of the touches and figure out when a multitouch gesture is happening and how much movement has taken place (I'm sure there are lots of sample code snippets for pinch to zoom)
Of course there is no reason you couldn't just write your own View class that did the same thing as GestureOverlayView except only with multitouch gestures, but if you still want the single touch gesture behaviour provided by GestureOverlayView then it this method would allow you to just add the multitouch support you need.
Upvotes: 1