Android 文本显示 - Canvas.drawText() 输出像素化

发布于 2024-10-17 15:59:09 字数 429 浏览 2 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初熏 2024-10-24 15:59:09

您还可以尝试使用 Paint.setAntiAlias(boolean)Paint.setSubpixelText(boolean)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文