开发者

Webview loadDataWithBaseURL not displaying html android

Trying to render html which is passed from a webservice to display in a webView using the loadData/loadDataWithBaseURL.

I've encoded the html string TextUtils.htmlEncode and wrapped it in <html> <body> but nothing is displayed.

mMessageDetailsHtmlString = &lt;html&gt;&lt;body&gt;&lt;div style=&quot;colo开发者_JAVA技巧r:#ffffff&quot; align=&quot;center&quot;&gt;&lt;h3&gt;Test Promo&lt;/h3&gt;&lt;/div&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;Here is some text about a great test promo.&lt;/p&gt;&lt;p style=&quot;color:#ffffff&quot;It includes an image (below) using a fully qualified URL&lt;p&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;&lt;img href=&quot;http://myserver.com/media/images/img-logo.png&quot; /&gt;&lt;/p&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;This is a test message with white text&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;

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


Looks the text in that html is white, is your webview's background white too by any chance?

Try mWebView.setBackgroundColor(Color.BLUE);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜