我在strings.xml中包含以下包含HTML标记的String:
<string name="login_title">Ihr Zugang für <br /> <u>zusätzliche</u> <br /> Business Inhalte</string>
布局:
<?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>
我给TextView
充气并在对话框中设置文字:
@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();
}
结果如下:
所以html完全被忽略了。我做错了什么?
答案 0 :(得分:0)
找到解决方案。
用<
<