Android:如何在不缩放的情况下居中裁剪图像
我想以缩略图形式显示一些图像,并且希望它们居中裁剪而不是缩放。图像本身几乎总是矩形的,我想围绕它们的中心裁剪它们并将它们放入方形 ImageView 中。位图本身要么具有与 ImageView 大小匹配的高度,要么具有匹配的宽度。所以本质上我只想裁剪每张照片的左/右或顶部/底部,而不损失任何质量。
当我尝试使用 ScaleType.CENTER_CROP 时,我的图像变得模糊。有什么建议吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该只使用 ScaleType.CENTER。这不会执行缩放,它只会将图像置于图像框后面的中心。任何落在 ImageView 之外的内容都将被裁剪。
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.