mudit mudit - 6 months ago 72
Android Question

Set transparent background of an imageview in Android

I am using a web view in which I am adding an image view. Now I want to set the background of this image view transparent. I have tried this:

mImageview.setBackgroundResource(R.color.trans);


Where
trans
=>
<color name="trans">#00000000 </color>
.

Answer

In your XML set Background attribute to any color White(#FFFFFF) shade or Black(#000000) shade. If you want transparency, just put another pair of hexadecimal numbers to represent the alpha (= transparency) before the actual color hash code. Adding 00 will make it completely transparent, FF completely opaque. For example, putting 80 will make it half-transparent:

#80000000

This will change any color you want to transparent one.. :)