Code example for ScaleGestureDetector

Methods: getCurrentSpangetFocusXgetFocusYgetPreviousSpangetScaleFactor

0
	 * This class handles the zoom gestures 
	 */ 
	private class ZoomHandler extends ScaleGestureDetector.SimpleOnScaleGestureListener {
	    @Override 
	    public boolean onScale(ScaleGestureDetector detector) {
	        scaleFactor *= detector.getScaleFactor();
	        // Prevent to much zoom but also less 
	        scaleFactor = Math.max(1.0f, Math.min(scaleFactor, 2.7f));
	         
	        int dirX = (int) (((size * 0.5) - detector.getFocusX()) / scaleFactor);
	        int dirY = (int) (((size * 0.5) - detector.getFocusY()) / scaleFactor);
	         
	        convertX = (int) (convertX + dirX * Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan()) * Math.max(detector.getScaleFactor() - 1, 0));
	        convertY = (int) (convertY + dirY * Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan()) * Math.max(detector.getScaleFactor() - 1, 0));
	         
	        convertX = (int) Math.max(Math.min(convertX, 0), - size + (size / scaleFactor));
        	convertY = (int) Math.max(Math.min(convertY, 0), - size + (size / scaleFactor));
	         
        	invalidate();
	        return true; 
Contextual code suggestions in your IDE  Get Codota for Java