Do multiple ImageView's holding the same image create extra Drawable objects or Drawable instances?
I currently have a ViewFlipper
that holds the same ImageView
in each screen. The issue is that I have to create an ImageView[]
array with a unique ImageView
per screen in the ViewFlipper
in order to add them to the ViewFlipper
since I run into the child already has a parent issue when using the same ImageView
. They all re开发者_开发问答fer to the same resource in R.drawable
.
My question is this: does every ImageView
in the array create a separate instance of the drawable object or do they each simply contain a reference to the same drawable object? Also, are ImageView
instances resource intensive? I'm worried that this would run into overhead issues, since this ImageView
array isn't the only one.
As far as drawables loaded from the same resource share a common state
it seems that android architects have thought of this question and the resources are used for 1 image only, so you won't get overhead in such way.
In addition: BitmapDrawables created from the same resource will for instance share a unique bitmap stored in their ConstantState.
精彩评论