Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off textview whitespace trimming?

I want to display a string with leading whitespace in a Textview. But what I can see is that the android Textview is trimming all leading/trailing whitespace. Is there a way to turn this behavior off?

like image 912
tmanthey Avatar asked Aug 10 '12 11:08

tmanthey


1 Answers

Old question but if you are not satisfied with "It Does Not trim itself." answer from comments this might help you.

If you are using resource strings with leading or trailing spaces, this is your issue: How to keep the spaces at the end and/or at the beginning of a String?

TextView indeed doesn't trim whitespaces but whatever reads strings from XML does. Use \u0020 instead of spaces.

like image 172
Emperor Orionii Avatar answered Nov 13 '22 04:11

Emperor Orionii