Android:如何用字符换行?(不是文字) [英] Android: How to wrap text by chars? (Not by words)
本文介绍了Android:如何用字符换行?(不是文字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
This is foo text for wrapping text in TextView
TextView的换行方式是:
The way that TextView wraps is:
This is foo text for
wrapping text in ...
我想要这个:
This is foo text for wr
apping text in TextView
推荐答案
这有点 hacky,但你可以用 unicode 不间断空格字符 (U+00A0) 替换空格.这将导致您的文本被视为单个字符串并以字符而不是单词换行.
It's a bit hacky, but you could replace spaces with the unicode no-break space character (U+00A0). This will cause your text to be treated as a single string and wrap on characters instead of words.
myString.replace(" ", "u00A0");
这篇关于Android:如何用字符换行?(不是文字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文