preface

In the project, I wanted to use Glide to load the URL to get the specific size of the picture. When I used the asBitmap() method, I received an error message indicating that there was no problem with the method. I thought there was a problem with the version

Glide.with(this).asBitmap().load(imaUrl).into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @nullable Transition<? Super Bitmap> Transition) {// This is a Bitmap glide mIvSaveImage.setImageBitmap(resource); bitmaps[0] = resource; }});Copy the code

Android handles incomplete display of images that are larger than width

Glide.with(context).asBitmap().load(item.getLogo()).into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @nullable Transition<? Super Bitmap> Transition) {int imageHeight = resource-.getheight (); int imageWidth = resource.getWidth(); If (imageHeight > imageWidth) {viewgroup.layoutParams para = iv.getLayoutParams(); para.width = (imageWidth / 4); para.height = (imageHeight / 4); iv.setLayoutParams(para); } else { ViewGroup.LayoutParams para = iv.getLayoutParams(); para.width = 180; para.height = 125; iv.setLayoutParams(para); } Glide. With (context). The load (item) getLogo ()). The thumbnail (0.5 f). Apply (options) into (iv); }});Copy the code