Tuesday, July 27, 2010

How to add leading and trailing spaces in string.xml

Even if you use string formatting sometimes you still need white spaces at the beginning or the end. On these cases neither escaping with \ nor using   or the xml:space attribute helps.
You must use the UTF character \u0020 for white spaces. Just type this succession of characters and it will be interpreted as a space. The \u part tells android that the following number represents the character in the UTF table.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. ok thank you for this tip, but how can we use that xml encoding, what is it ? i am googleing it like one hour and found nothing

    (deleted other one becouse of typo)

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I use code &#160 ; to add spaces.

    ReplyDelete