Stéphane Piette Stéphane Piette - 1 year ago 82
Android Question

Android - local image in webview

I'm trying to diplay a local image in my webview :

String data = "<body>" + "<img src=\"file:///android_asset/large_image.png\"/></body>";
webview.loadData(data, "text/html", "UTF-8");

This code doesn't display anything, instead of :


This one works, but I need to have complex web page, not just a picture.

Any ideas ?

Answer Source

Load Html file in Webview and put your image in asset folder and read that image file using Html.

        <img src="abc.gif" width="50px" alt="Hello">

Now Load that Html file in Webview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download