Android的HTML图像概率 [英] Android html image prob
本文介绍了Android的HTML图像概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用显示 loadData()
包含HTML code在网页视图的文本文件。在html code有一个像℃的图像标签; IMG SRC =文件:///android_asset/test.pngALT =CD4 +细胞>
和放在test.png文件中的水库\\绘制
文件夹中。但Webview是展现完美无IMG。哪里是在我的系统的万阿英,蒋达清?
I am displaying a text file that contains html code in a webview using loadData()
. The html code has a image tag like <img src="file:///android_asset/test.png" alt="cd4+ cell">
and placed the test.png file in the res\drawable
folder. But webview is displaying perfect without the img. Where is the probelm in my system?
推荐答案
尝试使用 loadDataWithBaseUrl()
而不是 loadData()
。事情是这样的:
Try using loadDataWithBaseUrl()
instead of loadData()
. Something like this:
public void loadHTML() {
final String mimeType = "text/html";
final String encoding = "utf-8";
final String html = "<img src=\"file:///android_asset/test.png\" />";
WebView wv = (WebView) findViewById(yourIDhere);
wv.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, "");
}
这篇关于Android的HTML图像概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文