znl_12 2013-03-20 01:59 采纳率: 0%
浏览 9984
已采纳

Webview loadDataWithBaseURL 不能显示 html

我想呈现一个 html,它是从 webservice 里面传过来的,使用loadData/loadDataWithBaseURL显示在一个 webview 中。

然后编码了 html string TextUtils.htmlEncode ,把它放在

里面,但是什么也显示不出来。
mMessageDetailsHtmlString = <html><body><div style="color:#ffffff" align="center"><h3>Test Promo</h3></div><p style="color:#ffffff">Here is some text about a great test promo.</p><p style="color:#ffffff"It includes an image (below) using a fully qualified URL<p><p style="color:#ffffff"><img href="http://myserver.com/media/images/img-logo.png" /></p><p style="color:#ffffff">This is a test message with white text</p></body></html>

//used loadDataWithBaseURL with a fake base url as loadData didn't work
mWebView.loadDataWithBaseURL("http://null", mMessageDetailsHtmlString, "text/html", "utf-8", null);
  • 写回答

1条回答

  • Baby_Bonnie 2013-03-20 07:28
    关注

    看起来 html 的文本是白色的,你设置的 webview 的背景有时候也是白色的吗?
    试用:

    mWebView.setBackgroundColor(Color.BLUE);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?