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

后端 未结 14 2119
谎友^
谎友^ 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: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:

    -4,\u00205,\u0020-5,\u00206,\u0020-6
    

    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.

提交回复
热议问题