开发者

Android: How to center crop images without scaling

开发者 https://www.devze.com 2023-01-28 15:44 出处:网络
I have some images I want to show in thumbnails, and I want them to center crop and not scale. The images themselves are almost always rectangular, and I want to crop them around their center and have

I have some images I want to show in thumbnails, and I want them to center crop and not scale. The images themselves are almost always rectangular, and I want to crop them around their center and have them fit into a square ImageView. The bitmaps themselves either have a height that matches the size 开发者_StackOverflow中文版of the ImageView, or a width that matches. So essentially I just want to crop off the left/right or the top/bottom of each photo, and not lose any quality.

When I try to use ScaleType.CENTER_CROP my images are becoming blurry. Any suggestions?


You should just use ScaleType.CENTER. This will perform no scaling, it will just center the image behind the image frame. Anything falling outside the ImageView will be cropped.

0

精彩评论

暂无评论...
验证码 换一张
取 消