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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
\u0020instead of spaces.