Extra Space in Android string.xml (ESAS)

I have defined several strings in the strings.xml file. Currently, I need to insert some extra spaces between some numbers in the string. However, when I add extra space characters, they don’t appear as expected in the app.

Before

<string name="spelatonertext3">-4, 5, -5, 6, -6,</string>

After

<string name="spelatonertext3">-4,  5, -5,   6,  -6,</string>

The result is the same.

Solution 

To use spaces in XML as a string, use &#160; instead of single spaces. XML does not handle empty spaces as-is; it trims whitespace before setting it. So, use &#160;.

Post a Comment

Previous Next

نموذج الاتصال