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?
If you have a string in your Res like this:
<string name="aaaa">aaaaaaaaaaaaaaaaa\n
bbbbbbbbbbbb\n
cccccccccccccc
</string>
Just just remove newlines. Your string must looks like:
<string name="aaaa">aaaaaaaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccccc</string>
Is it ok to display HTML? If yes:
textView.setText(Html.fromHtml("aaaa<br/>bbb<br/>cc<br/>d<br/>"));
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With