String html = “ < u > 1.1下划线,使用 HtmlCompat.from Html () ”;
//使用 HtmlCompat.from Html ()方法在 textview 下划线
SetText (HtmlCompat.from Html (html,HtmlCompat.FROM _ HTML _ MODE _ LEGACY)) ;
使用 strings.xml ,
<string name="underline_text">1.3 <u>Underline using HtmlCompat.fromHtml() and string resource</u></string>
inline var TextView.underline: Boolean
set(visible) {
paintFlags = if (visible) paintFlags or Paint.UNDERLINE_TEXT_FLAG
else paintFlags and Paint.UNDERLINE_TEXT_FLAG.inv()
}
get() = paintFlags and Paint.UNDERLINE_TEXT_FLAG == Paint.UNDERLINE_TEXT_FLAG