Android textview not supporting line break

For line break you use set text view in xml layout this way.

Now is the time \r\n for all good men to \r\n come to the aid of their \r\n party


Tried all the above, did some research of my own resulting in the following solution for rendering line feed escape chars:

string = string.replace("\\\n", System.getProperty("line.separator"));

1) using the replace method you need to filter escaped linefeeds (e.g. '\\n')

2) only then each instance of line feed '\n' escape chars gets rendered into the actual linefeed

For this example I used a Google Apps Scripting noSQL database (ScriptDb) with JSON formated data.

Cheers :D


I've been having the exact same problem under the exact same circumstances. The solution is fairly straight forward.

When you think about it, since the textview widget is displaying the text with the literal "\n" values, then the string that it is being given must be storing each "\n" like "\\n". So, when your XML string is read and stored, all occurrences of "\n" are being escaped to preserve that text as literal text.

Anyway, all you need to do is:

fireBody.setText(fireText.replace("\\n", "\n"));

Works for me!