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(寬度,高度){...}) –