Put   in string. xml file to indicate a single space in an android project.
XML ignores the first sequence of white space immediately after the opening tag and the last sequence of white space immediately before the closing tag. XML translates non-space characters (tab and new-line) into a space character and consolidates all multiple space characters into a single space.
In XML documents, there are two types of whitespace: Significant whitespace is part of the document content and should be preserved. Insignificant whitespace is used when editing XML documents for readability. These whitespaces are typically not intended for inclusion in the delivery of the document.
To add a space between the characters of a string, call the split() method on the string to get an array of characters, and call the join() method on the array to join the substrings with a space separator, e.g. str. split(''). join(' ') .
to use white space in xml as string use  
. XML won't take white space as it is. it will trim the white space before setting it. So use  
instead of single white space
Insert \u0020 directly in the XML for a blank you would like to preserve.
<string name="spelatonertext3">-4, \u00205, \u0020\u0020-5, \u00206, \u0020-6,</string>
Android doesn't support keeping the spaces at the end of the string in String.xml file so if you want space after string you need to use this unicode in between the words.
\u0020
It is a unicode space character.
This should work as well. Use quotes to maintain space
<string name="spelatonertext3">"-4, 5, -5, 6, -6,"</string>
As already mentioned the correct way to have a space in an XML file is by using \u0020
which is the unicode character for a space.
Example:
<string name="spelatonertext3">-4,\u00205,\u0020-5,\u00206,\u0020-6</string>
Other suggestions have said to use  
or  
but there is two downsides to this. The first downside is that these are ASCII characters so you are relying on something like a TextView to parse them. The second downside is that  
can sometimes cause strange wrapping in TextViews.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With