I\'m creating a custom view programmatically that is displaying text that is parsed from an XML file. The text is long and contains the \"/n\" character for force line brea
To force a line break through the XML of your textview, you need to use \r\n instead of just \n.
So, now your code in the XML becomes
android:text="Now is the time \r\n for all good men to \r\n come to the aid of their \r\n party"
Or if you want to do it programatically, then in your java code :
fireBody.setText("Now is the time \r\n for all good men to \r\n come to the aid of their \r\n party");
You can also declare the text as a string resource value, like this :
"some test line 1 \n some test line 2"
Another easy way to do it would be to change the default attribute of the TextView in your xml file.
And then use, textView.setText("First line \nSecond line \nThird line");