I draw two figures on the Canvas, each one is black, but it must have a different black transparency. I know that in xml you can set the transparency of the View using android: alpha, and how to do it on the Canvas?

  • one
    in the paint class, you can specify alpha. paint.setAlpha (alpha) - Android Android

1 answer 1

Color transparency is set by the first two hexadecimal digits:

#XXYYYYYY 

Where XX is the opacity , YYYYYY is the color code.
For example, the color #ff000000 is absolutely opaque black. ff - full opacity.
#7F000000 - half transparent black. 7FFFFFFF - Half transparent white.