(and helper class CompositeGestureDetector.)
RotateGestureDetector can detect two fingure rotation. You can implement rotation function such as Google Map.
Download jar and add to libs
directory.
You can use RotateGestureDetector as same as GestureDetector.
private RotateGestureDetector mRotateGestureDetector;
...
// onCreate etc.
OnRotateGestureListener listener = new OnRotateGestureListener() {
@Override
public boolean onRotate(float degrees, float focusX, float focusY) {
// implement your behavior here
return true;
}
};
mRotateGestureDetector = new RotateGestureDetector(context, listener);
...
@Override
public void onTouchEvent(MotionEvent e){
mRotateGestureDetector.onTouchEvent(e);
}
Simply copy directories in src
to your source tree.
If you want to use GestureDetector, ScaleGestureDetector and RotateGestureDetector together, it's time to use CompositeGestureDetector.
NOTE : CompositeGestureDetector needs android-support-v4.jar.
private CompositeGestureDetector gd;
...
// onCreate etc.
SimpleOnCompositeGestureListener listener = new SimpleOnCompositeGestureListener() {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// put your code
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
// put your code
return true;
}
@Override
public boolean onRotate(float degrees, float focusX, float focusY) {
// put your code
return true;
}
// ... and other methods
};
gd = new CompositeGestureDetector(context, listener);
...
@Override
public void onTouchEvent(MotionEvent e){
gd.onTouchEvent(e);
}
MIT License. See the LICENSE file for more info.