Android的xml的文字进行换行,string.xml文字换行

如果只是在xml里的话,在文字中间加上 \n 就可以了
示例;

 <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Hello \n blank fragment" />

string.xml文字换行及其它效果
为了方便统一管理,国际化等,我们通常把字符串保存在string.xml中,但这些字符串中直接输入一些符号不起任何作用,比如基本的换行、缩进、空格,这就要用转义字符来进行转义,这样才能给字符串添加样式。

常用的XML转义字符如下


    <string name="app_names">在上海6.30号\n建军节前一天,准备晚上去看灯光秀。</string>
    <string name="app_title">在上海6.30号\t建军节前一天,准备晚上去看灯光秀。</string>
    <string name="app_setting">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在上海6.30号, 准备晚上去看灯光秀。</string>
 
    <string name="app_others">3&lt;4 小于号</string>
    <string name="app_others1">99&gt;98 大于号</string>
    <string name="app_others2">A&amp;B 和</string>
    <string name="app_others3">&apos;B&apos; 单引号</string>
    <string name="app_others4">&quot;B&quot; 双引号</string>

猜你喜欢

转载自blog.csdn.net/ShiXinXin_Harbour/article/details/118363164
今日推荐