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

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

    As per your question if you want add spaces more than one in string resources their are many option to add spaces between character or word :

    1.By default one space you can add directly in string resource file it working fine. but if give more than one space inside string resources file then it exclude that spaces. eg . -4, 5, -5, 6, -6,

    1. If you want add more extra spaces inside string resource file then uses:- i. adding unicode after character like

          <string name="test">-4,&#160;&#160;5,&#160;&#160;-5,&#160;&#160;6,&#160;&#160;-6,</string>
      

    ii.you can use "\u0020"

    <string name="test">-4,\u0020\u0020 5,\u0020\u00205 -5,\u0020\u00205 6,\u0020\u00205 -6,</string>
    
    0 讨论(0)
  • 2020-12-12 13:54

    You want to it display like "-4, 5, -5, 6, -6," (two spaces),you can add the following code to string.xml

    <string name="spelatonertext3"> "-4,&#160;&#160;5,&#160;-5,&#160;&#160;6,&#160;&#160;-6,"</string>

      is display one space.

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

    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>
    
    0 讨论(0)
  • 2020-12-12 13:55

    If you are trying to give Space Between 2 string OR In String file of android then do this in your string file . Implement this before your "String name" that you want to show. \u0020\u0020 For E.g.. \u0020\u0020\u0020\u0020\u0020\u0020Payment

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

    Space variants:

    <string name="space_demo">|&#x20;|&#x2009;|&#x200A;|</string>
    

    | SPACE | THIN SPACE | HAIR SPACE |

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

    to use white space in xml as string use &#160;. XML won't take white space as it is. it will trim the white space before setting it. So use &#160; instead of single white space

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