Does Android cache drawable resources loaded in xml layout files?

Viewed 6914

I have a ViewPager which loads lots of fragments (+20). Each one of these fragments is just an instance of one single fragment, and the only thing that changes is the content of each one. The UI for this fragment has, among other widgets, 4 different ImageViews which all load the same resource drawable but are of course located in different parts of the UI.

Now, if we take into account that I might have for example 20 fragments with this scheme, we're talking about 80 (20*4) ImageViews which would all load the same drawable.

So, that made me wonder, does Android cache in any way resources that are loaded from xml layouts? If not, is there a better option then simply loading this drawable in code, caching it and attaching it programmatically to their corresponding ImageView every time a new instance of this fragment gets created?

Thanks.

3 Answers
Related