我是安卓新手。我正在做手势部分。我被卡住了,我找不到在 android 中检测其缩放或旋转手势(两指)的方法。
case MotionEvent.ACTION_MOVE:
if(event.getPointerCount() == 2) {
float currentX = event.getX();
Log.v(GlobalVars.TAG, (currentX - lastX) + "");
lastX = currentX;
double currentAngle = getAngle(event.getX(), event.getY());
Log.v(GlobalVars.TAG, "Rotation Y::" + (startAngle - currentAngle));
if((startAngle - currentAngle) > 0 && mRotate.y > (-1 * 45) && ) {
mRotate.y -= 1.0;
} else if((startAngle - currentAngle) < 0 && mRotate.y < 45) {
mRotate.y += 1.0;
}
startAngle = currentAngle;
}
private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
mOrigin.z *= detector.getScaleFactor(); // scale change since previous event
mOrigin.z = Math.max(MIN_ZOOM, Math.min(mOrigin.z, MAX_ZOOM)); //Max Zoom Value.
return true;
}
}