Code example for ScaleGestureDetector

Methods: getFocusX, getFocusY, getScaleFactor, isInProgress

0
 
		@Override 
		public boolean onScale( ScaleGestureDetector detector )
		{	 
			// Check if the detector is in progress in order to proceed 
			if(detector!=null && detector.isInProgress() ){
				try{ 
					// Grab the scale 
					float targetScale = getScale() * detector.getScaleFactor();
					// Correct for the min scale 
					targetScale = Math.min( maxZoom(), Math.max( targetScale, 1.0f) );
 
					// Zoom and invalidate the view 
					zoomTo( targetScale, detector.getFocusX(), detector.getFocusY() );
					invalidate();
 
					return true; 
				}catch(IllegalArgumentException e){
					e.printStackTrace();
				} 
			}