为什么textview中的换行符会导致换行符缩进?

Ric*_*ter 4 java mobile android android-3.0-honeycomb

<string
     This is a test\n
     This is another line.
/>
Run Code Online (Sandbox Code Playgroud)

当换行符(或下一行开头之前的空格)导致新行缩进1个空格时,我尝试在textview中显示此内容.显示基本上这看起来像 -

这是一个测试

This is another line

为什么会发生这种情况,我该如何解决这个问题?有线索吗?

nic*_*ild 6

我认为这与您在角色中添加的额外空白有关.我猜想Android将所有额外的空格视为单个空格(它也可能是解析器的一个功能,我不确定).

我想你宁愿做这样的事情来获得你期望的东西.

<resources>
    <string name="test_str">This is a test\nThis is another line.</string>
</resources>
Run Code Online (Sandbox Code Playgroud)