Home > OS >  line breaks in string resource
line breaks in string resource

Time:10-05

I have a long text in my string resources containing multiple line breaks. obviously i don't want to write it all in one line like <string name="text">This is the first line\nThis is the second line\n...</string> But when i do it like this:

<string name="text">
    This is the first line\n
    This is the second line\n
    ...
</string>

The start of the lines are indented a bit. How can i prevent this?

This is the first line
  This is the second line

i set the text ´directly in xml with android:text="@string/text"

CodePudding user response:

Remove the tabs when parsing ("\t") I think.

CodePudding user response:

one simple way is use "" in your text string, such as like this:

    <string name="text">
"This is the first line
This is the second line"
    </string>

CodePudding user response:

I use usually something like this below:

Image

You can use this also for long texts. You have to write this without tabs or spaces, just from the begin of the line like the photo.

Edited: "br tag" is used for new line

  • Related