Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set transparent background of an imageview on Android

I am using a web view in which I am adding an image view. How can I set the background of this image view to transparent?

I have tried this:

mImageview.setBackgroundResource(R.color.trans); 

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

like image 824
mudit Avatar asked Sep 29 '09 13:09

mudit


People also ask

How do I make an image transparent?

Double-click the picture, and when Picture Tools appears, click Picture Tools Format > Color. Click Set Transparent Color, and when the pointer changes, click the color you want to make transparent.

How do I make Constraintlayout transparent?

If you add this line to the Constraint Layout xml it will become transparent: android:background="@android:color/transparent" . This will make the background see through and show what ever is bellow or overlapping.

Is there a color code for transparent?

You can actually apply a hex code color that is transparent. The hex code for transparent white (not that the color matters when it is fully transparent) is two zeros followed by white's hex code of FFFFFF or 00FFFFFF.


1 Answers

You can set the background transparent of any layout, any view, or any component by adding this code in XML:

android:background="@android:color/transparent"  
like image 79
Chirag Patel Avatar answered Sep 19 '22 00:09

Chirag Patel