public static Bitmap scaleFit(Bitmap src,int maxW,int maxH){
  float ratio=Math.min(maxW / (float)src.getWidth(),maxH / (float)src.getHeight());
  int newW=(int)(src.getWidth() * ratio);
  int newH=(int)(src.getHeight() * ratio);
  return scale(src,newW,newH);
}

public static Bitmap scaleFit ( Bitmap src , int maxW , int maxH ) { float ratio = Math . min ( maxW / ( float ) src . getWidth ( ) , maxH / ( float ) src . getHeight ( ) ) ; int newW = ( int ) ( src . getWidth ( ) * ratio ) ; int newH = ( int ) ( src . getHeight ( ) * ratio ) ; return scale ( src , newW , newH ) ; }
scaling bitmap to fit required sizes . method keep aspect ratio .
