Glide.with(me)
.asBitmap()
.load("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3969660676,2975849700&fm=11&gp=0.jpg")
.into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
int width = resource.getWidth();
int height = resource.getHeight();
// 设置想要的大小
int newWidth = ScreenUtils.getScreenWidth();
int newHeight = newWidth * height / width;
// 计算缩放比例
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Glide加载长图,解决直接加载宽度留白,设置 scaleType=“centerCrop“ 展示不全问题
最新推荐文章于 2024-04-29 12:33:01 发布