0

I created an asset folder in android studio, and placed a png image called graph, the problem now is i created an html string and loaded it in a webview but the image does not display, here is my code below?

    String introString =" <html><body> \n" +
            "<img src=file:///assets/graph.png>"+
            "</body></html>";

    WebView wv = (WebView)this.findViewById(R.id.sexcompwebView);
    wv.getSettings().setDefaultFontSize(10);
    wv.getSettings().setBuiltInZoomControls(true);
    wv.getSettings().setDisplayZoomControls(false);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.loadDataWithBaseURL(null, introString, "text/html", "utf-8", null);

question is what am i missing?

Bels
  • 85
  • 8
  • you should set baseUrl "file:///android_asset/" instead "null" – MHP Oct 31 '15 at 07:44
  • i tried wv.loadDataWithBaseURL("file:///assets/graph.png",introString,"text/html", "utf-8",null); but there is nothing hoping you could post some code – Bels Oct 31 '15 at 08:07
  • refer [this](http://stackoverflow.com/questions/26424717/android-how-to-using-image-in-asset-folder-in-html-to-load-in-webview) , you may get some clue – Ichigo Kurosaki Oct 31 '15 at 08:13
  • it worked when i had to separately declare the image path then concatenate it in the image code. thanx – Bels Oct 31 '15 at 09:17

0 Answers0