map pinch zoom to 4 different scales in Android

74 views Asked by At

I want to pinch over a view and capture the zooming gesture and then map that to 4 different zooming scales. I figured out that I should use ScaleGestureDetector . I used it as follow and called in in the webview's on touch method.

mZoomGestureDetector = new ScaleGestureDetector(getActivity(), new OnScaleGestureListener()
        {

            @Override
            public void onScaleEnd(ScaleGestureDetector detector)
            {
                // TODO Auto-generated method stub

            }

            @Override
            public boolean onScaleBegin(ScaleGestureDetector detector)


{
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public boolean onScale(ScaleGestureDetector detector)
        {
            return false;
        }
    });


public boolean onTouch(View view, MotionEvent event)
    {

         mZoomGestureDetector.onTouchEvent(event);

        return true;

    }

I don't know how to use the detector.getScaleFactor() to map this to 4 differnt zooming levels. How to detect zooming in and out and not apply zoom if exceeds the maximum or minimum zoom levels.

0

There are 0 answers