使用资源,例如:
<string name="str">ends with a space </string>
最后失去的空间。
<string name="str">ends with a space </string>
保留了空间,但android将其视为一个不可破坏的空间。
有没有办法在资源字符串的末尾指定中断空格?这是针对库函数的,所以我不知道资源中可能指定了什么字符串。
显然我已经考虑过:
<string name="str">ends with a space£</string>
<string name="my_breaking_space_at_end_of_android_resource">£</string>
并使用regEx。
你似乎已经尝试了很多东西。您也可以尝试以下方法:
1) 只需在末尾留出空格,并将整个字符串用双引号括起来:
<string name="foo">"End with space "</string>.
2) 你也试过这个答案吗?这个答案说要尝试以下内容:
Insert u0020 directly in the XML for a blank you would like to preserve:
<string name="foo">End with space u0020</string>
希望这对你有帮助。