5.Glide使用之图片调整大小和缩放

本文介绍了使用Glide进行图片加载时的几种不同配置方法,包括resize调整大小、CenterCrop居中裁剪及FitCenter适应居中等技术,帮助开发者在带宽、内存消耗与图像质量间找到最佳平衡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通常来讲,这是最佳的如果您的服务器提供的图像是你需要准确的尺寸,这是一个完美的带宽、内存消耗和图像质量之间的平衡。
override(horizontalSize, verticalSize)

Glide
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .override(600, 200) // resizes the image to these dimensions (in pixel). does not respect aspect ratio
    .into(imageViewResize);

CenterCrop()

Glide
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .override(600, 200) // resizes the image to these dimensions (in pixel)
    .centerCrop() // this cropping technique scales the image so that it fills the requested bounds and then crops the extra.
    .into(imageViewResizeCenterCrop);

FitCenter()

Glide
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .override(600, 200)
    .fitCenter() 
    .into(imageViewResizeFitCenter);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值