score:216

Accepted answer

add \t for tab and \n for new line.

score:1

really all of the above did not work for me in android studio 4. what worked was:

<br>first line\n</br>second line

note: both \n and br-tags was needed.

score:2

  • include this line in your layout xmlns:tools="http://schemas.android.com/tools"
  • now , use \n for new line and \t for space like tab.
  • example :

    for \n : android:text="welcome back ! \nplease login to your account agilanbu"

    for \t : android:text="welcome back ! \tplease login to your account agilanbu"

score:3

add '\t' for tab

<string name="tab">\u0009</string>

score:4

for space use \t and for a new line use \n in your xml string, like

<string name="name">\tfirst sentence\nsecond sentence</string>

the output will be

    first sentence
second sentence

score:8

\n doesn't seem to work for tools:text

you can use <br/> to get a preview including line breaks, but it won't show up on the device unless you format the text using something like html.fromhtml()

score:12

you can use \n for new line and \t for tabs. also, extra spaces/tabs are just copied the way you write them in strings.xml so just give a couple of spaces where ever you want them.

a better way to reach this would probably be using padding/margin in your view xml and splitting up your long text in different strings in your string.xml

score:16

add this line at the top of string.xml

<?xml version="1.0" encoding="utf-8"?>

and use

'\n'

from where you want to break your line.

ex. <string> hello world. \n its awesome. <string>

output:

hello world.
its awesome.

score:25

use \t to add tab and \n for new line, here is a simple example below.

<string name="list_with_tab_tag">\tbanana\torange\tblueberry\tmango</string>
<string name="sentence_with_new_line_tag">this is the first sentence\nthis is the second scentence\nthis is the third sentence</string>

score:36

\n didn't work for me. so i used <br/> html tag

<string name="message_register_success">
    sign up is complete. <br/>
    enjoy a new shopping life at fatherofapps.com!!
</string>

score:38

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

more info:

https://developer.android.com/guide/topics/resources/string-resource.html


Related Query

More Query from same tag