androidcodehunter androidcodehunter -3 years ago 106
Android Question

How to set 20% alpha value for Android Imagebutton?

I have a problem in using alpha value. I know how to set alpha value for background but I don't know how to set 20% alpha value for ImageButton.

imageButton.setAlpha(?)


Can anyone give me full details tutorial on this topic by which I can understand this topic better?

Answer Source

You don't need a tutorial for this, just read the javadoc of the method, which says:

setAlpha() - Sets the opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

20% transparent then would mean a value of 0.2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download