Reputation: 23952
For example, in my Activity I have such code (I skip the initialization of variables):
ImageView iview; //some ImageView
Bitmap b; //some Bitmap
iview.setImageBitmap(b);
Question is - how to clear iview resources correctly (with or without destroying view) ? Would ImageView free it's resources (used in native code) after b.recycle()
?
I suppose, that ImageView doesn't just free it resources after Activity onStop
(or onDestroy
).
Upvotes: 14
Views: 37021
Reputation: 1384
if nothing is working for you try setting the background color of view to layout color.if my layout color is white u can do like this:
edit_countflag.setBackgroundColor(Color.parseColor("#ffffff"));
//then set the image
edit_countflag.setImageResource(R.drawable.flag_id);
Upvotes: 0
Reputation: 171
You can use frequently it works:
imageView.setImageResource(0);
Upvotes: 1
Reputation: 1189
viewToUse.setImageResource(android.R.color.transparent);
Upvotes: 0
Reputation: 40406
imgview.setImageResource(0);
or
imgview.setImageDrawable(null);
Upvotes: 42
Reputation: 29199
no you need to unbindDrawables, you can do it by setting iview.setImageDrawable(null);
Upvotes: 5