无法理解如何仅在 xml 中添加新行
Cannot understand how to add new line only in xml
请解释一下如何仅在 xml 中添加一个新行(当我将在程序中使用此字符串时,这必须是单行)?
例如:
<string name="test">This
is
test
line</string>
但是在程序中,当我使用 getString(R.string.test);
时,它会加载没有换行符的单个字符串:This is test line
。
我只需要它来格式化文件。
如果您想在 XML 字符串中强制换行,只需使用“\n”(假设您的 TextView 大小合适):
<string>This\nis\ntest\nline</string>
输出
这个
是
测试
行
参见:How to insert a new line in strings in Android
否则您可以插入空白 space  
或  
以调整您的字符串格式。
参见:How to put space character into a string name in XML?
请解释一下如何仅在 xml 中添加一个新行(当我将在程序中使用此字符串时,这必须是单行)?
例如:
<string name="test">This
is
test
line</string>
但是在程序中,当我使用 getString(R.string.test);
时,它会加载没有换行符的单个字符串:This is test line
。
我只需要它来格式化文件。
如果您想在 XML 字符串中强制换行,只需使用“\n”(假设您的 TextView 大小合适):
<string>This\nis\ntest\nline</string>
输出
这个
是
测试
行
参见:How to insert a new line in strings in Android
否则您可以插入空白 space  
或  
以调整您的字符串格式。
参见:How to put space character into a string name in XML?