How do I make the background of a Textview
about 20% transparent (not fully transparent), where there is a color in the background (i.e. white)?
To achieve this, use a color value which has an alpha channel—such as rgba. As with opacity , a value of 1 for the alpha channel value makes the color fully opaque. Therefore background-color: rgba(0,0,0,. 5); will set the background color to 50% opacity.
Use imageView. setAlpha(100) .
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.
Use the below code for black:
<color name="black">#000000</color>
Now if I want to use opacity then you can use the below code:
<color name="black">#99000000</color> <!-- 99 is for alpha and others pairs zero's are for R G B -->
And below for opacity code: and all opacity level here
100% — FF 95% — F2 90% — E6 85% — D9 80% — CC 75% — BF 70% — B3 65% — A6 60% — 99 55% — 8C 50% — 80 45% — 73 40% — 66 35% — 59 30% — 4D 25% — 40 20% — 33 15% — 26 10% — 1A 5% — 0D 0% — 00
If you always to forget what code for transparency then you must have to see below link and no worry about to remember anything regarding transparent code :-
https://github.com/duggu-hcd/TransparentColorCode
textviewHeader.setTextColor(Color.parseColor(ColorTransparentUtils.transparentColor(R.color.border_color,10)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With