glide默认是加载图片的原始比例大小,如果需要填充整个ImageView需要对图片进行裁剪

1.gradle中导入

implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

2.使用

Glide.with(context).load(file.toUri())
                .override(Constant.PICTURE_WIDTH, Constant.PICTURE_HEIGHT).centerCrop()
                .into(holder.sdvPicture)

注意 :
override中参数的宽高,并不是imageView布局xml的宽高,可以使用代码获取 View.getWidth()。

Logo

一站式 AI 云服务平台

更多推荐