【发布时间】:2018-04-05 19:31:35
【问题描述】:
我的strings.xml 中有以下行:
<string name="test_string">This is a <u>test</u></string>
在我的活动 xml 中,我在 TextView 中引用了这个字符串:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_string" />
奇怪的是,当我在我的设备(小米米 A1,Android 8.0)上运行该应用程序时,<u> 前面的空格也会加下划线。注意“a”和“test”之间带下划线的空格(来自实际设备的屏幕截图):
我也尝试在strings.xml 中使用以下内容:
<string name="test_string">This is a <u>test</u></string>
但结果是一样的。有什么想法吗?
【问题讨论】:
-
你试过 SpannableString 吗?
-
这很好用。我是 Android 开发新手,以前从未使用过 SpannableString,但感谢您的评论和一些谷歌搜索,我能够让它工作。还发布了详细的答案,以防有人遇到类似问题。
标签: android textview android-styles