As you can see from the image below, Android does not wrap my text as I would expect:
There is no space between the "-" and the "$", yet they are on different lines. The string is just defined like this:
<string name="hello_world">Hello stackoverflow. This text does not wrap well -$999,999,999.</string>
Is there any way to change this behaviour? I want "-$999,999,999" to wrap as if it were one word.
OK, I have the answer. There is a non-breaking hyphen ‑
(mentioned here ). All I needed to do was define the String like so:
<string name="hello_world">Hello stackoverflow. This text does not wrap well ‑$999,999,999.</string>
If I understood it correctly it is more a matter of text-formatting. If you want "-" and "$" to be on the same row, set the text as textView.setText("Hello stackoverflow. This text does not wrap well \\n -$999,999,999."). The "\\n" is interpreted as a new line
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.