Android - adding a image in html webview

后端 未结 4 710
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 01:39

Ok so the image i\'m using is called test.png and I have a java class (Cherry.java) and a xml class (cherry.xml) Also I have a html file in the /res/raw folder called htmlt

4条回答
  •  执念已碎
    2020-12-21 02:04

    First of all welcome to stackoverflow.

    Now put your html and image etc inside the Assets folder. And use the following code.

    Cherry.java

    WebView webview = (WebView) findViewById(R.id.abtus_webView);
    webview.loadUrl("file:///android_asset/index.html");
    

    htmltest.html

    
    

    I have put the images into the images Folder in Assets folder.This is working for me correct,I hope it helps you.

提交回复
热议问题