Android Development: Using Image From Assets In A WebView's HTML

后端 未结 6 2043
星月不相逢
星月不相逢 2020-11-28 07:37

In my app I\'m making a basic HTML help document. I wanted my app\'s logo in the HTML img tag itself, but I don\'t know how I\'d reference to the logo which will be stored i

6条回答
  •  情深已故
    2020-11-28 08:02

    Store the images in assets folder:

    enter image description here

    Read the image in the html from assets with file:///android_asset/

    for example:

    String sHtmlTemplate = "";
    

    load inside the WebView:

    webView.loadDataWithBaseURL(null, sHtmlTemplate, "text/html", "utf-8",null);
    

提交回复
热议问题