渲染*%{color:orange}的方法是什么?你好!!%*在android中的textview或webview中



什么是渲染%{color:orange}的方法你好!!%在android中的textview或webview中?

例如,Gmail将其呈现如下:*%{color:orange}Hello !!%*应在android textview/webview中呈现为该

同样的在网页中工作,但我想在android textview/webview 中渲染它

在布局XML中,尝试添加以下代码:

<TextView
android:id="@+id/your_text_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content" 
android:text="Hello !!"
android:textStyle="bold"
android:textColor="#FA8F20"/> <!-- This is the color you want -->

尝试使用Html.fromHtml对其进行格式化,并将其设置为TextView

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
textView.setText(Html.fromHtml("<font color=#FFA500>Hello !!</font>", Html.FROM_HTML_MODE_LEGACY))
} else { 
textView.setText(Html.fromHtml("<font color=#FFA500>Hello !!</font>");
}

最新更新