At some point, we need to set the background color for the UI page, for example, as seen in:
Note: The background color is #000000 and the transparency is 40%; How do you say it in code?
The first thing you need to know: the color and opacity (alpha) values are represented in hexadecimal notation. Regardless of the value range of a color is 0 to 255 (00 to FF). For alpha,00 to be completely transparent, FF is completely opaque.
The expression order is "AABBGGRR", in which Aa=alpha (00 to FF). Bb=blue (00 to FF). Gg=green (00 to FF). Rr=red (00 to FF). Like what. Suppose you want to apply a blue 50% opacity to an overlay, you should specify the lower face value: 7fff0000.
So how do you calculate the value of transparency? Take 40% as an example:
Calculation formula: 40*255/100= ... Convert to 16, can use calculator:
Did you see that. The alpha value of 40% is converted to 66; The value of the background to set the view in code is: #66000000
That's OK. Please correct me.
If in doubt, Welcome to QQ Group: 487786925 (Android Research and Development village)
Android Set Background transparency