Get the width of the edit field. (int returned) (e.g. 320 px)
Get the font width of your current text. Font class have getAdvance() method that accepts the string parameter (int returned) (e.g. 650 px)
if string width > edit field width you can divide string width and edit width and on the other step get the modulo of it. (here you will get 2 as division and 10 will be yr modulo. That means you have filled two lines + in third line you are having characters that can be fit into 10 px.
I hope it will solve your problem, but be careful if you use any long words, the module had never been tested with long words but I fear about result's accuracy with long words.
发布评论
评论(1)
获取编辑字段的宽度。 (int returned) (eg 320 px)
获取当前文本的字体宽度。
Font 类具有接受字符串参数的 getAdvance() 方法
(返回 int)(例如 650 px)如果字符串宽度 >编辑字段宽度
您可以将字符串宽度和编辑宽度相除,然后在另一步骤中获取它的模数。 (这里你将得到 2 作为除法,10 将是 yr 模。这意味着你已经填充了两行+在第三行中你有可以适合 10 px 的字符。我希望它能解决你的问题,但如果你使用任何长单词,请小心,该模块从未使用长单词进行过测试,但我担心长单词结果的准确性。 。
Get the width of the edit field. (int returned) (e.g. 320 px)
Get the font width of your current text.
Font class have getAdvance() method that accepts the string parameter
(int returned) (e.g. 650 px)if string width > edit field width
you can divide string width and edit width and on the other step get the modulo of it. (here you will get 2 as division and 10 will be yr modulo. That means you have filled two lines + in third line you are having characters that can be fit into 10 px.I hope it will solve your problem, but be careful if you use any long words, the module had never been tested with long words but I fear about result's accuracy with long words.