private boolean translate(float tx,float ty){
  mTranslateRect.set(mTempSrc);
  mMatrix.mapRect(mTranslateRect);
  final float maxLeft=mAllowCrop ? mCropRect.left : 0.0f;
  final float maxRight=mAllowCrop ? mCropRect.right : getWidth();
  float l=mTranslateRect.left;
  float r=mTranslateRect.right;
  final float translateX;
  if (mAllowCrop) {
    translateX=Math.max(maxLeft - mTranslateRect.right,Math.min(maxRight - mTranslateRect.left,tx));
  }
 else {
    if (r - l < maxRight - maxLeft) {
      translateX=maxLeft + ((maxRight - maxLeft) - (r + l)) / 2;
    }
 else {
      translateX=Math.max(maxRight - r,Math.min(maxLeft - l,tx));
    }
  }
  float maxTop=mAllowCrop ? mCropRect.top : 0.0f;
  float maxBottom=mAllowCrop ? mCropRect.bottom : getHeight();
  float t=mTranslateRect.top;
  float b=mTranslateRect.bottom;
  final float translateY;
  if (mAllowCrop) {
    translateY=Math.max(maxTop - mTranslateRect.bottom,Math.min(maxBottom - mTranslateRect.top,ty));
  }
 else {
    if (b - t < maxBottom - maxTop) {
      translateY=maxTop + ((maxBottom - maxTop) - (b + t)) / 2;
    }
 else {
      translateY=Math.max(maxBottom - b,Math.min(maxTop - t,ty));
    }
  }
  mMatrix.postTranslate(translateX,translateY);
  invalidate();
  return (translateX == tx) && (translateY == ty);
}

private boolean translate ( float tx , float ty ) { mTranslateRect . set ( mTempSrc ) ; mMatrix . mapRect ( mTranslateRect ) ; final float maxLeft = mAllowCrop ? mCropRect . left : 0.0f ; final float maxRight = mAllowCrop ? mCropRect . right : getWidth ( ) ; float l = mTranslateRect . left ; float r = mTranslateRect . right ; final float translateX ; if ( mAllowCrop ) { translateX = Math . max ( maxLeft - mTranslateRect . right , Math . min ( maxRight - mTranslateRect . left , tx ) ) ; } else { if ( r - l < maxRight - maxLeft ) { translateX = maxLeft + ( ( maxRight - maxLeft ) - ( r + l ) ) / 2 ; } else { translateX = Math . max ( maxRight - r , Math . min ( maxLeft - l , tx ) ) ; } } float maxTop = mAllowCrop ? mCropRect . top : 0.0f ; float maxBottom = mAllowCrop ? mCropRect . bottom : getHeight ( ) ; float t = mTranslateRect . top ; float b = mTranslateRect . bottom ; final float translateY ; if ( mAllowCrop ) { translateY = Math . max ( maxTop - mTranslateRect . bottom , Math . min ( maxBottom - mTranslateRect . top , ty ) ) ; } else { if ( b - t < maxBottom - maxTop ) { translateY = maxTop + ( ( maxBottom - maxTop ) - ( b + t ) ) / 2 ; } else { translateY = Math . max ( maxBottom - b , Math . min ( maxTop - t , ty ) ) ; } } mMatrix . postTranslate ( translateX , translateY ) ; invalidate ( ) ; return ( translateX == tx ) && ( translateY == ty ) ; }
translates the image . < p / > this method will not allow the image to be translated outside of the visible area .
