Uniform text wrapping in TextView

前端 未结 6 1396
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 06:34

I need nice text wrapping in TextView, especially for text in headers.

Text wrapping for TextView might look like this, where the last word is in new line:



        
6条回答
  •  借酒劲吻你
    2021-01-19 07:11

    You can add a '\n' in your string resouce xml to add a newline so you can managethe wrapping yourself.

    Another approach would be to dynamically add the '\n' where you get the string length divided by 2 and search for the next space in either direction and on the first find you just add '\n' there. A hack, but probably work.

    Other than that there is not much in Android for Hyphenation or Typography. Propably this post will give you some tips: http://smarter-than-the-average-pierre.blogspot.co.at/2011/10/bad-android-typography-tale-of-text.html

提交回复
热议问题