问题
So I have several ImageViews in a single Activity and all of them use the same image bitmap from a resource.
ImageViewOne.setImageResource(R.drawable.frequently_used_image);
ImageViewTwo.setImageResource(R.drawable.frequently_used_image);
ImageViewThree.setImageResource(R.drawable.frequently_used_image);
Does android allocate memory to load the bitmap once and reuse it for all other ImageViews using the same resource? Or does it load the bitmap each time it is set to an ImageView?
Thanks!
回答1:
Quoting Dianne Hackborn from Android team:
Also keep in mind that Resources already maintains a cache of Drawables for you, using this facility, so there is no need for you to implement your own cache for any Drawables you are retrieving from Resources.
from this answer: Consequences of drawable.setCallback(null);
来源:https://stackoverflow.com/questions/17098755/does-android-reuse-images-loaded-from-resource