开发者

Why does a newline character in textview cause the newline to be indented?

开发者 https://www.devze.com 2023-03-10 16:39 出处:网络
<string This is a test\\n This is another line. /> I try to show this in a textview when the newline (or the white space before the start of the next line) causes the new line to be indented by
<string
     This is a test\n
     This is another line.
/>

I try to show this in a textview when the newline (or the white space before the start of the next line) causes the new line to be indented by 1 blank space. Show basically th开发者_运维技巧is looks like -

This is a test

This is another line

Why is this happening and how do I fix this? Any clues?


I think it has to do with the extra whitespace you are adding yourself in the characters. I would guess that Android is treating all of your extra whitespace as a single space (it may also be a function of the parser, I am not sure).

I think you would rather do something like this to get what you are expecting.

<resources>
    <string name="test_str">This is a test\nThis is another line.</string>
</resources>
0

精彩评论

暂无评论...
验证码 换一张
取 消