如何在 Android 布局 xml
文件中定义 下划线 文本?
最佳答案
如果你使用 string resource 就可以实现xml 文件,它支持 HTML 标签,如 <b></b>
, <i></i>
和 <u></u>
.
<resources>
<string name="your_string_here"><![CDATA[This is an <u>underline</u>.]]></string>
</resources>
如果你想在代码中使用下划线:
TextView textView = (TextView) view.findViewById(R.id.textview);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
textView.setText(content);
关于android - 我可以在 Android 布局中为文本添加下划线吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2394935/