3

As you can see from the image below, Android does not wrap my text as I would expect: enter image description here

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.

Bradley Campbell
  • 9,298
  • 6
  • 37
  • 47
  • your question is text view was not wrap correctly. – Yugesh Aug 06 '13 at 11:27
  • Yep. It's not wrapping correctly, at least for what I want. I want to know if there is anything I can change to achieve the end result I am after. – Bradley Campbell Aug 06 '13 at 11:29
  • its not possible in default text view.[Refer this link you get better solution](http://stackoverflow.com/questions/4290877/justify-text-in-textview-android) – Yugesh Aug 06 '13 at 11:38

2 Answers2

1

OK, I have the answer. There is a non-breaking hyphen &#8209;(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 &#8209;$999,999,999.</string>
Community
  • 1
  • 1
Bradley Campbell
  • 9,298
  • 6
  • 37
  • 47
0

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

stevietheTV
  • 502
  • 6
  • 14
  • 2
    Yeah, but in a real scenario the $ value would be dynamic, and not always on the second line. Thanks for the answer anyway. I just posted the solution if you are interested. – Bradley Campbell Aug 06 '13 at 12:01