WebView页面中使用res中图片的方法:
<img id="img" src="file:///android_res/drawable/ic_launcher.png" />
附测试页面:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function loadimage(imageName) {
document.getElementById("img").src = "file:///android_res/drawable/" + imageName;
}
</script>
</head>
<body>
<img id="img" src="" />
</body>
</html>
private void loadimage(String imageName) {
String url = "javascript:loadimage('" + imageName + "');";
Log.e("Javascript Log", url);
webview.loadUrl(url);
}
调用:
loadimage("ic_launcher.png");