Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a background 20% transparent on Android

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)?

like image 435
Adham Avatar asked Jul 01 '12 22:07

Adham


People also ask

How do you make a half background transparent?

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.

How do I reduce opacity on my Android?

Use imageView. setAlpha(100) .

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

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

Hex Opacity Values

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))); 
like image 193
duggu Avatar answered Sep 21 '22 11:09

duggu