简体   繁体   中英

line breaks in string resource

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"

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

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>

I use usually something like this below:

图片

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM