Nha*_*tVM 29
\n对我不起作用。所以我使用了<br/>HTML 标签
<string name="message_register_success">
Sign up is complete. <br/>
Enjoy a new shopping life at fatherofapps.com!!
</string>
Run Code Online (Sandbox Code Playgroud)
Gri*_*ail 28
使用\n了断线之后,\t如果要插入一个标签.
您还可以使用一些XML标记进行基本格式化:<b>粗体文本,<i>斜体<u>文本和下划线文本
更多信息:
https://developer.android.com/guide/topics/resources/string-resource.html
小智 19
使用\ t为新行添加制表符和\n,下面是一个简单示例.
<string name="list_with_tab_tag">\tbanana\torange\tblueberry\tmango</string>
<string name="sentence_with_new_line_tag">This is the first sentence\nThis is the second scentence\nThis is the third sentence</string>
Run Code Online (Sandbox Code Playgroud)
Ank*_*ini 14
在 string.xml 的顶部添加这一行
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
并使用
'\n'
Run Code Online (Sandbox Code Playgroud)
从你想要断线的地方。
前任。 <string> Hello world. \n its awesome. <string>
输出:
Hello world.
its awesome.
Run Code Online (Sandbox Code Playgroud)
您可以使用\n新行和\t标签.此外,额外的空格/制表符只是按照您编写它们的方式复制,Strings.xml因此只需在您需要的位置提供几个空格.
更好的方法是在你的视图xml中使用填充/边距并在你的不同字符串中分割你的长文本 string.xml
小智 8
用于XML 字符串中的空间使用\t和新行使用,例如\n
<string name="name">\tFirst Sentence\nSecond Sentence</string>
Run Code Online (Sandbox Code Playgroud)
输出将是
First Sentence
Second Sentence
Run Code Online (Sandbox Code Playgroud)
\n 似乎不起作用 tools:text
您可以使用<br/>获得包括换行符在内的预览,但除非您使用类似的格式设置文本格式,否则它不会显示在设备上Html.fromHtml()
| 归档时间: |
|
| 查看次数: |
123295 次 |
| 最近记录: |