Code example for ScaleGestureDetector

Methods: getCurrentSpanX, getCurrentSpanY, getScaleFactor

0
	@Override 
	public boolean onScale(ScaleGestureDetector dScale) {
    	//.................................. 
		float[] m = new float[9];
		mMatrix.getValues(m);
		float ratio = dScale.getScaleFactor();
		float prevScale = m[Matrix.MSCALE_X];
        float newScale = prevScale * ratio; //Calc new matrix scale to test what the height will become.
		 
     	//.................................. 
    	//Limit how small image can scale 
    	float newHeight = mImgSize.oHeight * newScale;
    	 
    	if(newHeight < mViewSize.oHeight){
    		ratio = mViewSize.oHeight / (mImgSize.oHeight * prevScale);		
    		newScale = prevScale * ratio;
    	}//if 
    	 
    	mMatrix.postScale(ratio,ratio,dScale.getCurrentSpanX(),dScale.getCurrentSpanY());
    	 
    	//.................................. 
    	//when scaled small, need to realign x,y : keep at top and left 
    	mMatrix.getValues(m);
        float ymatrix = m[Matrix.MTRANS_Y];