<#h> 1
在早晨的早晨,在早晨的早晨,天空充满了加尔各答的天空。街上没有马车停下来,轮渡一直坚定不移,那些去法庭上法庭,去房子里并被厨房抓住的人,以及燃烧的柴火的烟雾厨房-面积如此之大-这个城市是加尔各答的坚强心脏,其数百条道路和小巷如今,黄金的趋势带动了今天一个奇妙的青年。
当我使用Html.format(value)时,它将打印但不是这种格式样式的解决方法
答案 0 :(得分:0)
尝试使用此:
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
} else {
return Html.fromHtml(html);
}
}
标记参数:
public static final int FROM_HTML_MODE_COMPACT = 63;
public static final int FROM_HTML_MODE_LEGACY = 0;
public static final int FROM_HTML_OPTION_USE_CSS_COLORS = 256;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE = 32;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_DIV = 16;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_HEADING = 2;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST = 8;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM = 4;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH = 1;
public static final int TO_HTML_PARAGRAPH_LINES_CONSECUTIVE = 0;
public static final int TO_HTML_PARAGRAPH_LINES_INDIVIDUAL = 1;
您可以详细了解Html class documentation
上的不同标志答案 1 :(得分:0)
如果您从strings.xml
中读取String资源,则可以通过如下包装将原始HTML插入值中:
<string name="morning_h1">
<![CDATA[
//This is where the html goes
<h1>During the morning of the morning of the morning, on the morning , etc.</h1>
]]>
</string>
在Java代码中将资源设置为TextView
,例如:
Textview morning = findViewById(R.id.morningTextView);
morning.setText(Html.fromHtml(getString(R.string.morning_h1)));
导致我获得此答案的来源(指的是更多来源):HTML header h1 tags not supported in TextView