如何给XML文件中的文本加下划线?我在textStyle中找不到选项。
发布于 2012-04-05 04:55:14
如果您正在使用字符串资源xml文件(支持HTML标签),则可以使用<b> </b>、<i> </i>和<u> </u>完成此操作。
<resources>
<string name="your_string_here">
This is an <u>underline</u>.
</string>
</resources>如果你想在代码中给某些东西加下划线,使用:
TextView tv = (TextView) view.findViewById(R.id.tv);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
tv.setText(content);希望这能有所帮助
发布于 2013-12-27 13:13:59
使用以下命令:
TextView txt = (TextView) findViewById(R.id.Textview1);
txt.setPaintFlags(txt.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);发布于 2012-04-05 15:06:35
<resource>
<string name="your_string_here">This is an <u>underline</u>.</string>
</resources>如果它不起作用,那么
<resource>
<string name="your_string_here">This is an <u>underline</u>.</string>
因为"<“在某些时候可能是一个关键字。
并用于显示
TextView textView = (TextView) view.findViewById(R.id.textview);
textView.setText(Html.fromHtml(getString(R.string.your_string_here)));https://stackoverflow.com/questions/10019001
复制相似问题