Filling spaces in string resources

In an Android text resource, how can I use a space?

For example, when I do a “result” and not a “result”, I still see the “result” in my textual representation of the application.

+81
android string
Dec 24 '11 at 13:14
source share
3 answers

Have you tried to surround your string with quotation marks? Maybe leading and trailing spaces are automatically deleted.

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

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

+148
Dec 24 '11 at 13:22
source share

As an alternative to Andreas Clober's answer, you can use this method:

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

In this case, the space character in unicode (\ u0020) is used.

+90
Dec 24 2018-11-12T00:
source share

Just do it

 <string name="str_name">" Hello World!</string> 
-7
Jul 29 '14 at 15:05
source share



All Articles