Code example for ScaleGestureDetector

Methods: getCurrentSpanX, getCurrentSpanY, getScaleFactor

0
 
	@Override 
	public boolean onScale(ScaleGestureDetector detector) {
		// TODO Auto-generated method stub 
		Log.d("Scaling", "Scaling: " + graphscaleY);
		if (detector.getCurrentSpanX()*2 < detector.getCurrentSpanY()) // Y bigger than X
			graphscaleY *= detector.getScaleFactor();
		else if (detector.getCurrentSpanY()*2 < detector.getCurrentSpanX()) // X bigger than Y
			graphscaleX *= detector.getScaleFactor();
		else { 
			graphscaleY *= detector.getScaleFactor();
			graphscaleX *= detector.getScaleFactor();
		} 
 
		// Don't let the object get too small or too large. 
		graphscaleY = Math.max(0.1f, Math.min(graphscaleY, 5.0f));
		graphscaleX = Math.max(0.1f, Math.min(graphscaleX, 5.0f));
 
		return true; 
	}