所以,在我的strings.xml中,我有一个非常长的文本,我想以某种方式格式化。如何在文本的第一句之前加上一个标签?另外,新线的代码是什么?谢谢
为标签添加\t
,为新线添加\n
。
如果要插入制表符,请使用\n
作为换行符和\t
。
您还可以使用一些XML标记进行基本格式化:<b>
用于粗体文本,<i>
用于斜体,<u>
用于带下划线的文本
更多信息:
https://developer.android.com/guide/topics/resources/string-resource.html
使用\ 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>
您可以使用\n
作为新行,使用\t
作为标签。此外,额外的空格/制表符只是按照你在Strings.xml
中编写它们的方式复制,所以只需给你想要它们的几个空格。
达到此目的的更好方法可能是在视图xml中使用填充/边距并在string.xml
中将长文本拆分为不同的字符串
为标签添加'\ t'
<string name="tab">\u0009</string>
在string.xml的顶部添加此行
<?xml version="1.0" encoding="utf-8"?>
并使用
'\n'
从哪里想要破坏你的路线。
恩。 <string> Hello world. \n its awesome. <string>
输出:
Hello world.
its awesome.
xmlns:tools="http://schemas.android.com/tools"
中包含此行\n
用于新行,\t
用于像tab这样的空间。android:text="Welcome back ! \nPlease login to your account agilanbu"
为\ t:android:text="Welcome back ! \tPlease login to your account agilanbu"