Resize image to fit screen size and resolution in Android [duplicate]
Solution 1:
You should try the different scaleTypes available. The documentation can be found here and (which I prefer) here is a very nice collection of examples of what these scaleTypes look like.
If you just want your image to be stretched and do not care about losing the aspect ratio, you might want to go with scaleType: fitXY
Solution 2:
Bitmap scaledBitmap = scaleDown(realImage, MAX_IMAGE_SIZE, true);
Scale down method
public static Bitmap scaleDown(Bitmap realImage, float maxImageSize,
boolean filter) {
float ratio = Math.min(
(float) maxImageSize / realImage.getWidth(),
(float) maxImageSize / realImage.getHeight());
int width = Math.round((float) ratio * realImage.getWidth());
int height = Math.round((float) ratio * realImage.getHeight());
Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
height, filter);
return newBitmap;
}