开发者

How to prevent words from breaking in textview when using wrap_content?

开发者 https://www.devze.com 2023-01-17 09:20 出处:网络
I am in the process of trying to convert a desktop app to Android - and am struggling with some very basic stuff.

I am in the process of trying to convert a desktop app to Android - and am struggling with some very basic stuff.

When I specify a layout 开发者_如何学运维including a textview that holds a sizable amount of text wrap_content seems to arbitrarily break in the middle of a word and I can not find any documentation indicating this can be controlled.


Try useing Ellipsize property of TextView.

"If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle"


Just posting this since none of the other solutions worked for me.

I had copied and pasted some text from online and I didn't realize it had weird spacing characters in that caused the text to wrap mid-word rather than at whitespace.

Here is the nasty character " " that looks like a space but isn't actually a space. I did a find and replace for this character and that solved my problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消