Android: how to center crop images without scaling

I have some images that I want to show in thumbnails, and I want them to center the crop, not scale. Images themselves are almost always rectangular, and I want to crop them around their center and paste them into an ImageView square. Bitmap images themselves have a height that matches the size of the ImageView or a width that matches. Therefore, in fact, I just want to crop the left / right or top / bottom of each photo and not lose any quality.

When I try to use ScaleType.CENTER_CROP, my images become blurry. Any suggestions?

+3
source share
1 answer

You just need to use ScaleType.CENTER. It will not scale, it will just center the image outside the image frame. Anything outside of ImageView will be truncated.

+8
source

Source: https://habr.com/ru/post/1778448/


All Articles