Android textview not supporting line break

后端 未结 7 1530
遥遥无期
遥遥无期 2020-12-31 02:30

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

相关标签:
7条回答
  • 2020-12-31 03:09

    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

    0 讨论(0)
提交回复
热议问题