如何在android中显示html中的图片?
我用mWebView = new WebView(context);
LayoutParams lpmWebView = new LayoutParams(-1, -1);
WebSettings wSet = mWebView.getSettings();
wSet.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/a.html");
mWebView.getSettings().setLoadsImagesAutomatically(true);//自动加载图片
的方法加载html页面的时候,图片不显示,该怎么办?其他内容是显示的
这是我的a.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">--------------------编程问答-------------------- 除 --------------------编程问答-------------------- var imageURL="file://android_asset/1.jpg";
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript">
//背景颜色
var loadingBgcolor = "#444444";
//问题就在这里,不论我输入网络图片还是本地地址,都不显示
var imageURL="file://android_asset/1.jpg";
//宽度
var loadingWidth = 354;
/*
*参数说明:
*content:显示内容,可以为空;
*imageURL:将引用JS文件的路径设置即可;
*left:进度条显示位置left
*top:进度条显示位置top
*/
function show(msg)
{
document.getElementById("showmsg").innerHTML = msg;
}
function showUpdate(step)
{
show(step);
imgAct.width += step;
if(imgAct.width > loadingWidth-4)
{
imgAct.width = 0;
}
}
function LoadTable(content,sleft, top)
{
show("imageURL:"+imageURL);
var strLoading;
strLoading = "";
strLoading += "<div id=\"showimage\" style=\"DISPLAY:none;Z-INDEX:100;LEFT:" + left+ "px;POSITION:absolute;TOP:" + top+ "px;\" align=\"center\">";
strLoading += "<TABLE id=\"Table1\" cellSpacing=\"0\" cellPadding=\"0\" width=\"" + loadingWidth + "\" border=\"0\">";
if(content != "")
{
strLoading += "<tr>";
strLoading += "<td align=\"center\">";
strLoading += "<font size=\"4\" face=\"Courier New, Courier, mono\"><strong>" + content + "</strong></font>";
strLoading += "</td>";
strLoading += "</tr>";
strLoading += "<TR>";
}
strLoading += "<TD class=\"Loading\" height=\"20\">";
strLoading += "<IMG id=\"imgAct\" height=\"20\" alt=\"\" src=\"" + imageURL + "\" bgcolor=\"" + loadingBgcolor + "\" width=\"30\">";
strLoading += "</TD>";
strLoading += "</TR>";
strLoading += "</TABLE>";
strLoading += "</div>";
document.getElementById("loading_div").innerHTML = strLoading;
}
</script>
</head>
<body>
<div id="show_div">
<span id="showmsg">sss</span>
<br/>
<input type="button" name="Button" value="Button" onclick="LoadTable('显示',20,100)">
</div>
<div id="loading_div" ></div>
</body>
</html>
这样肯定不行的。你就在页面上写个img标签试试
<img src="1.jpg">
//把1.jpg和html放一个目录
补充:Java , Java相关