gilde 版本 4.5.0
Glide.with(this)
.load(url)
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
image.setImageDrawable(resource);
float width = DeviceUtils.getScreenWidth(); //获取屏幕宽度
float scale = width/resource.getMinimumWidth(); //缩放比例
//缩放后的宽度和高度
int afterWidth = (int) (resource.getMinimumWidth() * scale);
int afterHeight = (int) (resource.getMinimumHeight() * scale);
ViewGroup.LayoutParams lp = image.getLayoutParams();
lp.width = afterWidth;
lp.height = afterHeight;
image.setLayoutParams(lp);
}
});