如何使图像永远在记忆中毕加索
How to make an image always in memory Picasso
我刚开始在 Android 中使用 Picasso,但我发现当 Picasso 加载太多图像时会导致内存不足,并且之前加载的图像将从内存中删除,所以当我回来时,毕加索将再次从互联网加载。我只想让一些重要的图像永远留在记忆中,比如头像。
我应该将图像存储在磁盘内存中还是使用其他库或其他东西 else.Can 有人指导我解决方案吗?
你可以Glide
满足你的要求,它是一个强大的图像加载库
在您的应用中gradle执行此操作
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
Usage:-
Glide.with(context)
.load(url_here)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(holder.imageView);
这是缓存所有版本图像的密钥DiskCacheStrategy.ALL
我刚开始在 Android 中使用 Picasso,但我发现当 Picasso 加载太多图像时会导致内存不足,并且之前加载的图像将从内存中删除,所以当我回来时,毕加索将再次从互联网加载。我只想让一些重要的图像永远留在记忆中,比如头像。 我应该将图像存储在磁盘内存中还是使用其他库或其他东西 else.Can 有人指导我解决方案吗?
你可以Glide
满足你的要求,它是一个强大的图像加载库
在您的应用中gradle执行此操作
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
Usage:-
Glide.with(context)
.load(url_here)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(holder.imageView);
这是缓存所有版本图像的密钥DiskCacheStrategy.ALL