I want to set a long text with break line in string.xml
I couldn't insert break line for all
for example:
my text : It is a test 1.It is a test 2.
It is a test 3.
It is a test 4.
.
.
.
It is a test 500.
It is a test 501.
I want to change to:
It is a test 1
It is a test 2
It is a test 3
It is a test 4
.
.
.
It is a test 500
It is a test 501
Asked
Active
Viewed 981 times
-1

amirmamed
- 41
- 6
-
where you want shw this text?? – mayuri Dec 20 '13 at 13:13
-
4use "\n" .......... – a.ch. Dec 20 '13 at 13:15
-
1Use \n within your strings. That's the escape sequence for a newline character. – NigelK Dec 20 '13 at 13:15
-
1Use \n for a line break – Linga Dec 20 '13 at 13:16
-
A simple search gives many answers.... http://stackoverflow.com/questions/2877828/line-break-in-xml-formatting – stefana Dec 20 '13 at 13:22
2 Answers
2
Insert "\n" where you want your text to jump on next line.
I.e.:
myText = myText.replace(". ", "\n")
in xml layout:
android:text="My very long long\nlong long long long\nlong long text"

Phantômaxx
- 37,901
- 21
- 84
- 115
-
-
-
As I showed... by code, with a replace or manually in xml (you can let a text editor - even the internal one - do that for you) – Phantômaxx Dec 20 '13 at 14:20
0
Simply use this
<string name="sample_string"><![CDATA[It is a test 1 <br />It is a test 2]]></string>

Linga
- 10,379
- 10
- 52
- 104