Line Break in XML formatting?


when editing a String in XML I need to add line breaks. And I wanted to ask what is the RIGHT form when programming for android? Because <br> works but ECLIPSE marks the area as problematic. If I check out suggestions Eclipse tells me that I shall add a end tag </br> - IF I add that the line break dissapears...

So the one works but is marked as problematic, the other works not but Eclipse tells me its ok..

What form shall I use?

8/23/2012 12:35:21 AM

Accepted Answer

Use \n for a line break and \t if you want to insert a tab.

You can also use some XML tags for basic formatting: <b> for bold text, <i> for italics, and <u> for underlined text.

Other formatting options are shown in this article on the Android Developers' site:

9/24/2016 12:12:12 AM

If you are refering to res strings, use CDATA with \n.

<string name="about">
 Author: Sergio Abreu\n

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow