So, in my strings.xml I have a very long text which I want to format somehow. How can I put a tab before the first sentence of the text? Also, what is the code for new line? Thanks
11 Answers
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
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
- 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"