How to put space character into a string name in XML?

后端 未结 14 1949
谎友^
谎友^ 2020-12-12 13:31

i have defined some strings in the strings.xml file. Now I need to put some extra space between some numbers in the string. When I type extra space characters t

相关标签:
14条回答
  • 2020-12-12 14:01

    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.

    0 讨论(0)
  • 2020-12-12 14:04

    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 &#160; or &#032; 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 &#160; can sometimes cause strange wrapping in TextViews.

    0 讨论(0)
提交回复
热议问题