">
当前位置:   article > 正文

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

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

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

 <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Hello \n blank fragment" />
  • 1
  • 2
  • 3
  • 4

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>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/242882?site
推荐阅读
相关标签
  

闽ICP备14008679号