gpt4 book ai didi

android - 我可以在 Android 布局中为文本添加下划线吗?

转载 作者:IT老高 更新时间:2023-10-28 12:48:37 30 4
gpt4 key购买 nike

如何在 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com