android规模手势如何运作?

时间:2012-08-27 17:39:14

标签: android android-gesture

在ScaleGesture中,android如何计算detector.getScaleFactor();中的比例因子以及在哪个范围内?

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
            @Override
            public boolean onScale(ScaleGestureDetector detector) {
                mScaleFactor *= detector.getScaleFactor();

                // Don't let the object get too small or too large.
                mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 15.0f));
                _renderer.z=-mScaleFactor;
                invalidate();
                return true;
            }
       }

1 个答案:

答案 0 :(得分:2)

如果您搜索捏,基本上会根据源代码找到相同的公式:

mScaleFactor = getCurrentSpan() / getPreviousSpan();

当前夹点的距离除以第一个/旧夹点。