Android 在TextView上呈现HTML不起作用
我的strings.xml中包含以下包含HTML标记的字符串:Android 在TextView上呈现HTML不起作用,android,Android,我的strings.xml中包含以下包含HTML标记的字符串: <string name="login_title">Ihr Zugang für <br /> <u>zusätzliche</u> <br /> Business Inhalte</string> 结果如下: 因此html被完全忽略了。我做错了什么?找到了解决方案 替换所有 <?xml version="1.0" encoding="utf-8"?
<string name="login_title">Ihr Zugang für <br /> <u>zusätzliche</u> <br /> Business Inhalte</string>
结果如下:
因此html被完全忽略了。我做错了什么?找到了解决方案
替换所有
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxWidth="686dp"
android:orientation="vertical">
<TextView
android:id="@+id/login_textview_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/textcolorprimary"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = this.activity.getLayoutInflater();
AlertDialog.Builder builder = new AlertDialog.Builder(this.activity);
View rootView = inflater.inflate(R.layout.dialog_login, null);
TextView textViewTitle = (TextView) rootView.findViewById(R.id.login_textview_title);
textViewTitle.setText(Html.fromHtml(this.getResources().getString(R.string.login_title)));
builder.setView(rootView);
builder.setCancelable(false);
return builder.create();
}