-1

I am trying to add leading white space (spaces) to the string displayed in my TextView when I use setText(), but TextView just removes them from the String.

For example, say I want to display " 328". I call textView.setText(" 328"), but what is displayed in the TextView is "328". The TextView will always display:

328

Instead of:

 328

Please keep in mind that I must solve this while using .setText() and not through resources. I have also tried prepending it with "\u00A0","\u0020", and "&#160" but they don't work.

MarkInTheDark
  • 244
  • 2
  • 15
  • 2
    Possible duplicate of [How to keep the spaces at the end and/or at the beginning of a String?](http://stackoverflow.com/questions/1587056/how-to-keep-the-spaces-at-the-end-and-or-at-the-beginning-of-a-string) – Dayan Mar 03 '17 at 18:39
  • .setText(" " + "328"); – Sanyam Jain Mar 03 '17 at 18:39

1 Answers1

2

use this below method to add space before text.

textView.setText("     "+"328");
Narendra Sorathiya
  • 3,770
  • 2
  • 34
  • 37