简体   繁体   English

在J2ME画布上显示格式化的文本

[英]Showing formatted text on J2ME canvas

I want to show some text from my .ashx file on my J2ME canvas. 我想在我的J2ME画布上显示.ashx文件中的一些文本。 But the '\\n's used in original don't work here and all I get is a straight line. 但是原始的'\\ n'在这里不起作用,我得到的只是一条直线。 How do I add that formatting in here? 如何在此处添加该格式?

Thanks. 谢谢。

As far as I am aware there is no way to add formatting when displaying a String on a Canvas. 据我所知,在画布上显示字符串时无法添加格式。 You will have to manually add it yourself. 您将必须自己手动添加它。

I guess you could parse the text into individual lines and then display each line in turn using graphics.drawString() 我猜您可以将文本解析为单独的行,然后使用graphics.drawString()依次显示每一行

You can use font.getStringWidth() and font.getHeight() to check that your string will appear within the bounds of your canvas. 您可以使用font.getStringWidth()和font.getHeight()来检查字符串是否出现在画布的边界内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM