【问题标题】:How can I add a breaking space at the end of an android string resouce如何在 android 字符串资源的末尾添加一个分隔空间
【发布时间】:2013-06-19 04:40:20
【问题描述】:

使用如下资源:

<string name="str">ends with a space </string>

结尾丢失的空间。

<string name="str">ends with a space&#160;</string>

保留空间,但 android 将其视为非中断空间。

有没有办法在资源字符串的末尾指定一个换行符?这是一个库函数,所以我不知道资源中可能指定了哪些字符串。

显然我考虑过:

<string name="str">ends with a space£</string>
<string name="my_breaking_space_at_end_of_android_resource">£</string>

并使用正则表达式。

【问题讨论】:

    标签: android


    【解决方案1】:

    你似乎尝试了很多东西。您还可以尝试以下方法:

    1) 只需在末尾留一个空格并将整个字符串用双引号括起来:

    <string name="foo">"End with space "</string>. 
    

    2) 你也试过this 回答,上面说试试以下:

    Insert \u0020 directly in the XML for a blank you would like to preserve:

    <string name="foo">End with space \u0020</string>
    

    希望这对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-20
      • 2012-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 2010-10-10
      相关资源
      最近更新 更多