Android 文本显示 - Canvas.drawText() 输出像素化
我的 Android 应用程序以几种不同的方式显示文本,它们之间存在一些令人烦恼的差异,我希望人们能够提供帮助。
当我使用可能被称为“自动”的显示方法时,文本显示得非常好。通过自动方法,我指的是工具,例如 Toast 和 Button 小部件,我只需在其中提供文本,然后操作系统(或“环境”或其他)为我显示它。这些字母弯曲得很好,看起来很舒服,而且很容易辨认。
但是,在我处理文本显示的代码中(在 Surface Runner 视图中使用 Canvas.drawText()),文本质量很差。文字仍然清晰,但看起来像素化。这些字母看起来不太好。
我尝试过使用 Paint.setTypeface()
(例如使用 Typeface.SANS_SERIF)进行实验,但当它是我的代码时,显示质量总是很差。可行,但很差。
还有其他人经历过吗?有没有人有解决办法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以尝试使用
Paint.setAntiAlias(boolean)
或Paint.setSubpixelText(boolean)
。You might also try playing around with
Paint.setAntiAlias(boolean)
orPaint.setSubpixelText(boolean)
.