我正在使用SurfaceHolder
andScaleGestureDetector
让我的缩放工作。在两者之间SurfaceHolder.lockCanvas()
我surfaceHolder.unLockCanvasAndPost(canvas)
执行缩放操作。
canvas.scale(mScaleFactor, mScaleFactor, scalePointX,scalePointY);
在 onScaleMethod 中,我执行以下操作
public boolean onScale(ScaleGestureDetector detector) {
mScaleFactor *= detector.getScaleFactor();
// Don't let the object get too small or too large.
mScaleFactor = Math.max(1.0f, Math.min(mScaleFactor, 35f));
scalePointX=(detector.getFocusX());
scalePointY=(detector.getFocusY());
Log.i("Zoom",mScaleFactor+"");
return true;
}
但是画布不会在两个手指之间的中心缩放。我应该如何调整 scalePointX 和 scalePointY 的值以使代码正常工作。
谢谢