Android - adding a image in html webview

后端 未结 4 709
被撕碎了的回忆
被撕碎了的回忆 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 01:50

    Create this directory assets/www

    then place your html and image etc inside the www folder. And use the following code.

    Cherry.java

    webview.loadUrl("file:///android_asset/www/htmltest.html");
    

    htmltest.html

    nothing
    

提交回复
热议问题