简体   繁体   English

android 中的 Webview 不会从 res/drawable 加载图像

[英]Webview in android does not load image from res/drawable

This is my code:这是我的代码:

webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            view.loadUrl("file:///android_res/drawable/sale_screen_20170912.jpg");
        }
    });

I want to load an image from drawable resource when receiving an error from webview.当收到来自 webview 的错误时,我想从可绘制资源加载图像。 But this is what I got when try to load this image from drawable folder.但这是我尝试从可绘制文件夹加载此图像时得到的。

在此处输入图像描述

API level of the project is 17. API项目等级为17。

Try this尝试这个

        webView.loadDataWithBaseURL("file:///android_res/drawable/", "<img src='sale_screen_20170912.jpg' />", "text/html", "utf-8", null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM