最好的选择是自己处理缓存,它可以为您提供更多控制权,并且应该很容易,因为您已经知道要加载哪些位图。
首先:设置一个LruCache
LruCache<String, Bitmap> memCache = new LruCache<>(size) { @Override protected int sizeOf(String key, Bitmap image) { return image.getByteCount()/1024; }};第二:将位图加载到LruCache
Display display = getWindowManager().getDefaultDisplay();Point size = new Point();display.getSize(size);int width = size.x; //width of screen in pixelsint height = size.y;//height of screen in pixelsGlide.with(context) .load(Uri.parse("file:///android_asset/imagefile")) .asBitmap() .fitCenter() //fits given dimensions maintaining ratio .into(new SimpleTarget(width,height) { // the constructor SimpleTarget() without (width, height) can also be used. // as suggested by, An-droid in the comments @Override public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { memCache.put("imagefile", resource); } });第三:使用缓存的位图
Bitmap image = memCache.get("imagefile");if (image != null) { //Bitmap exists in cache. imageView.setImageBitmap(image); } else { //Bitmap not found in cache reload it Glide.with(context) .load(Uri.parse("file:///android_asset/imagefile")) .into(imageView);}


