Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enforcing spaces in string resources [duplicate]

Tags:

string

android

In an Android string resource, how do I enforce a space?

For example, when I do " result" rather than "result" I still see "result" in my application's text view.

like image 837
SK9 Avatar asked Dec 24 '11 13:12

SK9


2 Answers

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".

like image 70
Andreas Klöber Avatar answered Oct 02 '22 18:10

Andreas Klöber


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).

like image 26
Lasse Samson Avatar answered Oct 02 '22 18:10

Lasse Samson