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

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

    The only way I could get multiple spaces in middle of string.

    <string name="some_string">Before" &#x20; &#x20; &#x20;"After</string>
    
    Before   After
    
    0 讨论(0)
  • 2020-12-12 13:43

    This should work as well. Use quotes to maintain space

    <string name="spelatonertext3">"-4,  5, -5,   6,  -6,"</string>
    
    0 讨论(0)
  • 2020-12-12 13:45

    Put &#160; in string.xml file to indicate a single space in an android project.

    0 讨论(0)
  • 2020-12-12 13:45

    You can use following as well

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

    Put anything in " "(quotation) with space, and it should work

    0 讨论(0)
  • 2020-12-12 13:45

    If the output is HTML, then in HTML multiple spaces display as a single space. To prevent this, use non-breaking spaces (xA0) instead of ordinary spaces.

    0 讨论(0)
  • 2020-12-12 13:48

    xml:space="preserve"

    Works like a charm.

    Edit: Wrong. Actually, it only works when the content is comprised of white spaces only.

    Link

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