Home » Android » Android Text Display – Canvas.drawText() output pixelated

Android Text Display – Canvas.drawText() output pixelated

Posted by: admin June 15, 2020 Leave a comment

Questions:

My Android app displays text in a few different ways, and there are some annoying differences between them I was hoping folks could help with.

When I use display methods that might be termed “automatic,” the text is displayed very nicely. By automatic methods, I’m referring tools, like Toasts and Button widgets where I just have supply the text, and the OS (or “environment” or whatever) displays it for me. The letters are nicely curved, pleasant to look at, and easily legible.

However, in my code where I handle the text display (using Canvas.drawText() in a Surface Runner View), the text quality is poor. The text is still legible, but it looks pixelated. The letters just don’t look their best.

I’ve tried experimenting with Paint.setTypeface(), using Typeface.SANS_SERIF for example, but the quality of the display when it’s my code is always poor. Doable, but poor.

Has anybody else experienced this? By any chance does anybody have a solution?

How to&Answers:

You might also try playing around with Paint.setAntiAlias(boolean) or Paint.setSubpixelText(boolean).