Android TextView 下划线不起作用
Android TextView underline works not
我想做一件简单的事情 - 在 TextView 中为文本添加下划线。字符串放在 strings.xml 中(因为翻译):
<string name="mytext"><u>UnderlineText</u></string>
然后我以编程方式输入文本:
TextView txt1 = findViewById(R.id.autor);
txt1.setText(resources.getString(R.string.mytext));
但是,由于某种原因,字符串文件中的 <u>
被忽略,我的文本没有下划线。
我也试过:
txt1.setText(Html.fromHtml(resources.getString(R.string.mytext)));
仍然没有。文字正常显示,没有下划线。
替换为:
<string name="mytext"><![CDATA[<u>UnderlineText</u>]]> </string>
尝试使用 getText() 而不是 getString()。
txt1.setText(resources.getText(R.string.mytext));
此 returns 包含样式的本地化字符串。
我想做一件简单的事情 - 在 TextView 中为文本添加下划线。字符串放在 strings.xml 中(因为翻译):
<string name="mytext"><u>UnderlineText</u></string>
然后我以编程方式输入文本:
TextView txt1 = findViewById(R.id.autor);
txt1.setText(resources.getString(R.string.mytext));
但是,由于某种原因,字符串文件中的 <u>
被忽略,我的文本没有下划线。
我也试过:
txt1.setText(Html.fromHtml(resources.getString(R.string.mytext)));
仍然没有。文字正常显示,没有下划线。
替换为:
<string name="mytext"><![CDATA[<u>UnderlineText</u>]]> </string>
尝试使用 getText() 而不是 getString()。
txt1.setText(resources.getText(R.string.mytext));
此 returns 包含样式的本地化字符串。