Android使用WebView加载外部html使用本地图片资源

不使用拦截重定向的方式。
在外部的html中设置了本地文件的绝对路径例如:


<img src="file:///android_asset/ic_launcher.png">

但是webView加载html时图片不显示 这是什么原因?如何解决?

http不应该用tomcat获取本地图片嘛

这个html在浏览器打开能看到图片吗?

用shouldInterceptRequest替换

 public WebResourceResponse shouldInterceptRequest(WebView view,  String url) {
    Log.i(LOGTAG, "shouldInterceptRequest url=" + url + ";threadInfo" + Thread.currentThread());
    WebResourceResponse response = null;
    if (url.contains("ic_launcher")) {
        try {
            InputStream localCopy = getAssets().open("ic_launcher.png");
            response = new WebResourceResponse("image/png", "UTF-8", localCopy);
        } catch (IOException e) {
            e.printStackTrace();
        }        
    }
    return response;
}