如何删除Android TextView上的第一个字符缩进
我在 Android 上使用 TextView 在屏幕上显示多行文本,如下所示。
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n ccccccccccccccccccccccccccccccccccccccccccccccc\n dddddddddddddddd\n
如果我将它放置到 TextView,我会得到以下结果..
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbb\n cccccccccccccccccccccccc ccccccccccccccccccccccc\n dddddddddddddddd\n
我希望看到..如下所示..
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbb\n cccccccccccccccccccccccc ccccccccccccccccccccccc\n dddddddddddddddd\n
我的意思是我不需要为每行的第一个空格自动缩进。
如何去掉自动缩进?
I am using TextView on Android to display multiline text on screen like the below.
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n ccccccccccccccccccccccccccccccccccccccccccccccc\n dddddddddddddddd\n
If I place it to TextView, I have the below result..
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbb\n cccccccccccccccccccccccc ccccccccccccccccccccccc\n dddddddddddddddd\n
I wish to see.. like below..
aaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbb\n cccccccccccccccccccccccc ccccccccccccccccccccccc\n dddddddddddddddd\n
I mean I do not need auto indent for first space of each line.
How to remove the auto indent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果你的Res中有一个像这样的字符串:
只需删除换行符即可。您的字符串必须如下所示:
If you have a string in your Res like this:
Just just remove newlines. Your string must looks like:
将
\n
放在新行前面,Put the
\n
in front of the new line,可以显示HTML吗?如果是:
Is it ok to display HTML? If yes:
如果将 \n 放在每行末尾(一行上适合屏幕的字符数),则下一行将像第一行一样缩进。基本上你不会去掉缩进,而是缩进每一行。
如果您只有几行需要管理,那么这是可行的,但如果您有很多文本,则应该寻找更好的解决方案。
if you put \n at the end of each line (amount of characters that fit on the screen on one line), the next one will be indented just like the first. basically you don't get rid of the indentation, but rather indent every line instead.
this works, if you have just a few lines to manage, but if you have a lot of text, you should look for a better solution.