【问题标题】:Style in the body tag not affect the Android WebViewbody 标签中的样式不会影响 Android WebView
【发布时间】:2021-11-26 08:26:57
【问题描述】:

我得到一个这样的 html 代码:

<!DOCTYPE html>
<html>
  <head>
    <title></title>
  </head> 
  <body style="font-family:Open Sans">    
    <p><strong> Dumy /strong></p>
    <p>
      Dumyp
    </p>
    <p>
      Dumyp2
    </p>
    <p>
      Dumyp3
    </p>
  </body>
</html>

我正在像这样将这个 html 数据设置到我的 webView 中

webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient());
webView.setLongClickable(false);
webView.setOnLongClickListener(v -> true);
webView.setHapticFeedbackEnabled(false);
webView.setWebChromeClient(new WebChromeClient());
webView.loadData(productsResultObject.getProductDetail(), "text/html; charset=utf-8", "UTF-8");
webView.setHorizontalScrollbarOverlay(false);

我的网页视图上的字体没有改变。

【问题讨论】:

  • 字体导入了吗?

标签: android html css webview fonts


【解决方案1】:

您的代码是正确的,但您必须添加所需字体类型的链接,您可以使用其他属性。要使用字体,请从 google 字体复制字体链接

【讨论】:

    猜你喜欢
    • 2017-12-05
    • 1970-01-01
    • 2011-11-23
    • 2016-10-05
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 2020-02-07
    相关资源
    最近更新 更多