1

In the ScaleGesture how android calculate the scale factor in detector.getScaleFactor(); and in which range?

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;
            }
       }
Mohit
  • 2,940
  • 2
  • 24
  • 32
Rolando Corratge Nieves
  • 1,233
  • 2
  • 10
  • 25

1 Answers1

2

If you search for pinch you will find the same formula basically and according to the source code:

mScaleFactor = getCurrentSpan() / getPreviousSpan();

It's the distance of the current pinch divided by the first/old pinch.

Marcio Covre
  • 4,556
  • 2
  • 22
  • 24
  • this is not working on android 6.0 See my question : http://stackoverflow.com/questions/39594539/scalegesturedetector-getscalefactor-always-returning-1-0-in-android-6-0 – Mohammad Haidar Sep 20 '16 at 14:02