1

Is it possible to set transparency in gradient which is set in the XML file?

2 Answers 2

9

Say you have a gradient with 2 colors:

  • StartColor #111111
  • EndColor #333333

Adding transparency is as simple as adding 2 HEX digits to the beginning of each color

SO:

If you want the StartColor (for example) to be 100% opaque:

  • change its value to #FF111111

If you want the EndColor (for example) to be 100% transparent:

  • change its value to #00333333

You can of course use values between 00 and FF for transparency if you don't want the extreme values.

The values between HEX 00 and FF are values between 0 and 255 in normal numbers:

To transform from [0,255] to [00,FF]:

  1. Open calculator in windows and change mode to scientific
  2. There are options like : Dec, Hex, Oct ...

    Choose Dec and type the number between 0 and 255

  3. Choose Hex and the number will become in hex between 00 and FF
Sign up to request clarification or add additional context in comments.

3 Comments

Where can I find the values between 00 and FF? Let's say I want 55% transparency.
I think I found the link en.wikipedia.org/wiki/Web_colors#HTML_color_names which lead me to conclusio. HEX has 16 values (1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) where 8 is 50%, etc. This way I can set transparency up t0 6.25% precision (100 / 16). Is there a more precise way? Maybe some online tool?
open calculator in windows: View -> Scientific Now enter a number between 0 and 255 (0 is 00 and 255 is FF) Choose Hex and you will get the value
3

You should be able to use #AARRGGBB format for the start/end colors, with the AA portion specifying the alpha channel (i.e., transparency).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.