Enforcing spaces in string resources

As an alternative to the answer given by Andreas Klöber you can use this method:

<string name="foobar">foo \u0020 bar</string>

This utilizes the unicode space character (\u0020).


Did you try to surround your string with quotes? Maybe leading and trailing whitespaces are stripped automatically.

<string name="foo">" bar"</string>

See the example at https://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling in section "Escaping apostrophes and quotes".

Tags:

String

Android