android重用从资源加载的图像吗?

时间:2013-06-13 23:15:13

标签: android bitmap android-imageview android-resources

所以我在一个Activity中有几个ImageView,它们都使用来自资源的相同图像位图。

ImageViewOne.setImageResource(R.drawable.frequently_used_image);
ImageViewTwo.setImageResource(R.drawable.frequently_used_image);
ImageViewThree.setImageResource(R.drawable.frequently_used_image);

android是否分配内存一次加载位图并将其重用于使用相同资源的所有其他ImageView?或者它是否每次>将位图加载到ImageView?

谢谢!

1 个答案:

答案 0 :(得分:5)

从Android团队引用Dianne Hackborn:

  

另请注意,Resources已经使用此工具为您维护了Drawables的缓存,因此您无需为从Resources中检索的任何Drawable实现自己的缓存。

来自这个答案:Consequences of drawable.setCallback(null);