Search code examples
androidgraphicscanvasdrawtextcontrast

Android: DrawText with background contrast


How to "set up" a paint to accomplish the "second" image above?

paint.setColor(Color.BLACK);
canvas.drawText(strValue, x, y, paint);

enter image description here

First Image: text all in black as result of that code above.

Second Image: better constrat to backgroud colors (edited with graphic editor just to illustrate here)

Note that "31" is partially black and partially white (but it could be any other color with a better contrast to red, as "36" could be to blue).


Solution

  • You could draw with PixelXorXfermode.