如何制作新的行或标签 XML(eclipse / android)?

问题描述 投票:86回答:7

所以,在我的strings.xml中,我有一个非常长的文本,我想以某种方式格式化。如何在文本的第一句之前加上一个标签?另外,新线的代码是什么?谢谢

android xml eclipse tabs line
7个回答
148
投票

为标签添加\t,为新线添加\n


27
投票

如果要插入制表符,请使用\n作为换行符和\t

您还可以使用一些XML标记进行基本格式化:<b>用于粗体文本,<i>用于斜体,<u>用于带下划线的文本

更多信息:

https://developer.android.com/guide/topics/resources/string-resource.html


18
投票

使用\ 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>

9
投票

您可以使用\n作为新行,使用\t作为标签。此外,额外的空格/制表符只是按照你在Strings.xml中编写它们的方式复制,所以只需给你想要它们的几个空格。

达到此目的的更好方法可能是在视图xml中使用填充/边距并在string.xml中将长文本拆分为不同的字符串


3
投票

为标签添加'\ t'

<string name="tab">\u0009</string>

1
投票

在string.xml的顶部添加此行

<?xml version="1.0" encoding="utf-8"?>

并使用

'\n'

从哪里想要破坏你的路线。

恩。 <string> Hello world. \n its awesome. <string>

输出:

Hello world.
its awesome.

0
投票
  • 在您的布局xmlns:tools="http://schemas.android.com/tools"中包含此行
  • 现在,使用\n用于新行,\t用于像tab这样的空间。
  • 示例: 为\ n:android:text="Welcome back ! \nPlease login to your account agilanbu" 为\ t:android:text="Welcome back ! \tPlease login to your account agilanbu"
© www.soinside.com 2019 - 2024. All rights reserved.