Canvas drawText with gradient color - android

Is that possible to draw text on Canvas with gradient color in Andorid?
For example, draw letter A with top part is red while bottom part is blue?
Thanks

Related

how to drawText transparent with background Path in Canvas Drawable?

how to drawText transparent with background Path in Canvas Drawable?
https://i.stack.imgur.com/RkS41.jpg
Do you want a transparent background with text on it like the first battery indicator?
If so create two Paint objects: one with alpha value (from 0 to 255) to draw the transparent background, the other one to draw your text.

canvas drawText and emoji alpha color

the design recommendation for android regarding text legibility (https://material.io/design/color/text-legibility.html#legibility-standards) says to use for the font a black color with Alpha 87% or 60% depending on the importance of the text. So I paint text on my canvas like this :
paint.setColor(#99000000);
canvas.drawText('a text 🚫 with emoji', x, y, paint);
This work well for the text, It looks a little grayed and not pure black, however, the emoji 🚫 is also painted with the alpha and for a colored image, this is not good to use Alpha to draw it :(
On iOS, for example, emoji are drawn without taking care of the alpha of the font color. Is there any way under Android to draw a text on the canvas with font color alpha that will be applied only to the text and not for the emoji contained in the text?

How would you do this in canvas drawing

How would you draw something like this programmatically in a ondraw method? I know how to draw lines or squares, but to have an image inside a squarebox that has an arrow, is kind of confusing for me
Thank you
Just break the drawing up in different elements:
a gray box
a white rounded rectangle
a white rectangle
a blue rectangle
a blue rounded rectangle
a blue triangle
a red heart (I would just try to find a font with a nice heart)
the text in white.
Draw it all to the canvas in this order and you are fine.

How to show a shaded glow outside a circle in android

How to show a shaded glow blended with the background color when you draw a circle on a canvas in android.
My circle is orange colored and the background is blue. I am trying to show a halo of white color which fades to the background color

Android, canvas: How can I draw transparent circle without overprinting?

Stage 1. I have a background
Stage 2. I apply an overlay to background with a canvas to draw. First I fill the whole area with canvas.drawColor(Color.argb(128,0,0,0))
Then I need to draw a red transparent circle with color.argb(128,255,0,0) at a specified place, but I want circle red transparency replaced black filling transparency, not added. So, I wanna get this
but NOT this
How can I get it?
You can try to use Canvas.clipPath before filling area with black color to exclude area, which will be used later by circle.

Categories

Resources