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) ?
To make a new line or tab in string XML, add \t for tab and \n for new line.
- \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
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>
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
<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>
Add ‘\t’ for tab
<string name="tab">\u0009</string>
- 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"
<TextView
android:id="@+id/txtTitlevalue"
android:text="Line1: \n-Line2\n-Line3"
android:layout_width="54dip"
android:layout_height="fill_parent"
android:textSize="11px" />