Accepted answer

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


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.


  • include this line in your layout xmlns: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"


add '\t' for tab

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


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


\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()


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


add this line at the top of string.xml

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

and use


from where you want to break your line.

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


hello world.
its awesome.


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>


\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!!


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:

Related Query

More Query from same tag