我想提请我下面的的TextView
下划线。我寻觅了一些内容,但找不到任何东西卓有成效的。
I want to draw the underline below my TextView
. I have searched a few content but couldn't find out anything fruitful.
任何人都可以请帮我在这里?
Can anyone please help me out here?
有三种方式中的TextView下属的文字。
There are three ways of underling the text in TextView.
SpannableString
setPaintFlags(); TextView中的
setPaintFlags(); of TextView
Html.fromHtml();
让我解释一下你的所有方法:
Let me explain you all approaches :
1日法
有关在TextView中下属的文字,你必须使用SpannableString
For underling the text in TextView you have to use SpannableString
String udata="Underlined Text";
SpannableString content = new SpannableString(udata);
content.setSpan(new UnderlineSpan(), 0, udata.length(), 0);
mTextView.setText(content);
2日法
您可以使用setPaintFlags TextView中的方法强调的TextView的文本。
You can make use of setPaintFlags method of TextView to underline the text of TextView.
有关,例如。
mTextView.setPaintFlags(mTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mTextView.setText("This text will be underlined");
您可以参考的常量,如果你想打这个文本涂料类。
第三个方法
请使用 Html.fromHtml的(htmlString);
String htmlString="<u>This text will be underlined</u>";
mTextView.setText(Html.fromHtml(htmlString));