Android TextView HTML中的换行符



可能重复:
如何在Android文本视图中添加换行符?

我试图用上标和其他文本用三行不同的文字来表达一个数字,但由于某种原因,换行符不起作用。

TextView tvAnswer = (TextView)findViewById(R.id.textView_answer);
tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext nistextonanotherline"));

"\n"不会导致换行,但它没有我需要的"Html.fromHtml"。

这也不起作用:

tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext<br>istextonanotherline"));

因为Android显然不支持br HTML标记。帮助

一种可能的解决方案是

tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext "));
    tvAnswer.append("n");

最新更新