HTML5标签在Android上无法正确呈现

时间:2018-07-20 05:04:25

标签: html5 xamarin.android

无法在Android 7.0上正确呈现html,并且没有加下划线。下面是我用来渲染的代码:

ISpanned displayText;
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
{
    displayText = Html.FromHtml(item.attributes.attributeLabel, Android.Text.FromHtmlOptions.ModeLegacy);
}
else
{
    displayText = Html.FromHtml(item.attributes.attributeLabel);
}

label.SetText(displayText, TextView.BufferType.Spannable);

HTML

<p style="text-align:center;"><span style="font-size: 16px;"><strong><ins>OFFICE USE ONLY </ins></strong></span></p>

我认为这是由于<ins>标签引起的。我的代码有什么问题吗?

1 个答案:

答案 0 :(得分:0)

以下是使用FromHtml方法在Android Textview中支持的标记

Html.fromHtml支持

index <- grepl(paste0(company_key, collapse = "|"), data$company, ignore.case = TRUE) | grepl(paste0(brand_key, collapse = "|"), data$company, ignore.case = TRUE) data[index,] # company brand vol #1 Coca-Cola Inc. Coca-Cola Zero 2456 #2 DF, CocaCola N/A 1653 #3 COCA-COLA Coca-Cola 19 #5 Beverages Distribution soft drink 167  <p>  <ul>  <li>  <div>  <span>  <strong>  <b>  <em>  <cite>  <dfn>  <i>  <big>  <small> <font>  <blockquote>  <tt>  <a>  <u>  <del>  <s>  <strike>  <sup>  <sub>  <h1>  <h2> <h3>  <h4> <h5>  <h6>  <img>

Android不支持以下标记以外的任何内容,因此我想是<br>引起的问题。