0
所以我有一个关于Glide的基本问题。我做一个android测试应用程序,只是想要转换图像以适应屏幕。Glide的真正基本的东西
这是旧代码:
Bitmap background, backgroundresized;
(...)
//load image
background = BitmapFactory.decodeResource(context.getResources(), R.drawable.gamebackground);
}
void onDraw(Canvas canvas) {
if(first_time){
width = canvas.getWidth();
height = canvas.getHeight();
backgroundresized = Bitmap.createScaledBitmap(background, width, height, true);
first_time=false;
}
canvas.drawBitmap(backgroundresized, 0, 0, null);
}
这并不适合屏幕最好的方法,我知道,我用这个和绘制-xhdpi/xxhdpi/xxxhdpi文件夹。
但如何使用Glide来做到这一点,并希望回收图像,如果用户回到这个屏幕?
滑翔提供覆盖的大小。阅读文档:https://futurestud.io/tutorials/glide-image-resizing-scaling –
我不与ImageViews一起工作。 – csant85
然后它有自定义的目标,调整工作方式相同。您可以添加像.into(SimpleTarget(宽度,高度){...}) –