我想写一个段落作为移动应用程序的一部分。我该怎么做呢?
答案 0 :(得分:12)
使用\ n打破行。
示例:
TextView t = findViewById(R.id.text);
t.setText("This is the first line\nThis is the second line\nThird line...");
答案 1 :(得分:5)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_with_paragraphs">
Can this contain a lot of text? Can it contain \n a newline? Yes, it can.
Adding a 2nd line like this should work.
It should not cause parsing errors.
</string>
<resources>
所以你可以像这样引用它:
android:text="@string/text_with_paragraphs"
参考:http://www.experts-exchange.com/Programming/Smartphones/Android/Q_27925834.html