我希望我的TextView
看起来像这样:
以下是activity_main.xml
TextView
代码
<TextView
android:id="@+id/txtOut"
android:layout_below="@+id/txtIn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25sp"
android:textColor="@android:color/black"
android:scrollbars="vertical"
android:text="@string/song"
/>
正如您所看到的,最后一个属性android:text="@string/song"
将文字设置为来自R.strings
的字符串。R.strings
我的歌曲看起来就像我想要的那样,但当我运行时应用程序,它看起来像这样
如何让它看起来像我想要的那样?
答案 0 :(得分:4)
如果要返回回车,则需要将结束行字符\ n放在strings.xml文件中。你的歌会像这样开始:
<string name="song">jingle bells, jingle bells\njingle all the way\n...</string>
答案 1 :(得分:0)
strings.xml
中的字符串应如下所示:
<string name="song">
Jingle bells, jingle bells\n
Jingle all the way\n
Oh, what fun it is to ride\n
In a one horse open sleigh\n\n
Hey, jingle bells, jingle bells\n
Jingle all the way\n
Oh, what fun it is to ride\n
In a one horse open sleigh\n\n
Jingle bells, jingle bells\n
Jingle all the way\n
Oh, what fun it is to ride\n
In a one horse open sleigh\n\n
Hey, jingle bells, jingle bells\n
Jingle all the way\n
Oh, what fun it is to ride\n
In a one horse open sleigh\n\n
</string>