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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?