question: private void updateBaseMatrix ( Drawable d ) { if ( null == d ) { return ; } final float viewWidth = getWidth ( ) ; final float viewHeight = getHeight ( ) ; final int drawableWidth = d . getIntrinsicWidth ( ) ; final int drawableHeight = d . getIntrinsicHeight ( ) ; baseMatrix . reset ( ) ; final float widthScale = viewWidth / drawableWidth ; final float heightScale = viewHeight / drawableHeight ; if ( scaleType == ScaleType . CENTER ) { baseMatrix . postTranslate ( ( viewWidth - drawableWidth ) / 2F , ( viewHeight - drawableHeight ) / 2F ) ; } else if ( scaleType == ScaleType . CENTER_CROP ) { float scale = Math . max ( widthScale , heightScale ) ; baseMatrix . postScale ( scale , scale ) ; baseMatrix . postTranslate ( ( viewWidth - ( drawableWidth * scale ) ) / 2F , ( viewHeight - ( drawableHeight * scale ) ) / 2F ) ; } else if ( scaleType == ScaleType . CENTER_INSIDE ) { float scale = Math . min ( 1.0f , Math . min ( widthScale , heightScale ) ) ; baseMatrix . postScale ( scale , scale ) ; baseMatrix . postTranslate ( ( viewWidth - ( drawableWidth * scale ) ) / 2F , ( viewHeight - ( drawableHeight * scale ) ) / 2F ) ; } else { RectF mTempSrc = new RectF ( 0 , 0 , drawableWidth , drawableHeight ) ; RectF mTempDst = new RectF ( 0 , 0 , viewWidth , viewHeight ) ; switch ( scaleType ) { case FIT_CENTER : baseMatrix . setRectToRect ( mTempSrc , mTempDst , Matrix . ScaleToFit . CENTER ) ; break ; case FIT_START : baseMatrix . setRectToRect ( mTempSrc , mTempDst , Matrix . ScaleToFit . START ) ; break ; case FIT_END : baseMatrix . setRectToRect ( mTempSrc , mTempDst , Matrix . ScaleToFit . END ) ; break ; case FIT_XY : baseMatrix . setRectToRect ( mTempSrc , mTempDst , Matrix . ScaleToFit . FILL ) ; break ; default : break ; } } resetMatrix ( ) ; }
target:  Calculate Matrix for FIT_CENTER