programmatically remove background picture from image view in android
I have set a background image in inmage view in 开发者_Go百科my android application. Now I want to remove this background picture programmatically. How to do this?
imgView.setImageResource(android.R.color.transparent);
Try this:
imgView.setImageBitmap(null);
The accepted answer removes the image resource of the image view ,if you want to remove the background resource then do
imageView.setBackgroundResource(android.R.color.transparent);
also adding in some explanation, this actually doesnot remove the background resource completely,it will just replace the existing background resource with a transparent color ,so it appears like the background is removed.
You can also try:
imageView.setImageDrawable(null)
This will remove the image associated with your imageView
. Similarly, if you want to add another image, you can use:
imageView.setImageDrawable(_your_drawable_object_).
As the name suggests, this takes a drawable object not an int.
精彩评论