How to make a new line or tab in string XML (eclipse/android) ?

How to make a new line or tab in string XML (eclipse/android) ?

Asked on January 5, 2019 in XML.
Add Comment


  • 8 Answer(s)

    To make a new line or tab in string XML, add \t for tab and \n for new line.

    Answered on January 5, 2019.
    Add Comment
    • \n for a line break
    • \t to insert a tab.

    Also can use some other XML tags like: <b> for bold text, <i> for italics, and <u> for underlined text

    Answered on January 5, 2019.
    Add Comment

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

    Simple example:

    <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>
    
    Answered on January 5, 2019.
    Add Comment

    Use \t to add tab and \n for new line, here is a simple example below. 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

    Answered on February 28, 2019.
    Add Comment
    <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>
    Answered on February 28, 2019.
    Add Comment

    Add ‘\t’ for tab

    <string name="tab">\u0009</string>
    Answered on February 28, 2019.
    Add Comment
    • 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"

    Answered on February 28, 2019.
    Add Comment
    <TextView
       android:id="@+id/txtTitlevalue"
       android:text="Line1: \n-Line2\n-Line3"
       android:layout_width="54dip"
       android:layout_height="fill_parent"
       android:textSize="11px" />
    Answered on February 28, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.