我的代码:
web.loadData("<html><body> " + result.getHtmltext().replaceAll("<span class=\"stl_23 stl_10\" style=\"word-spacing:0em;\">-------------------------------</span>",
"<img height=\" 500\" width=\"500\" src=" + " \" " + "file:///android_asset/logo_transparent.png" + "\" " + "/>") + "</body></html>", "text/html; charset=UTF-8", null);
最佳答案
你可以试试看
String htmlData = "<body>" + "<img src=\"logo_transparent.png\"/></body>";
webView.loadDataWithBaseURL("file:///android_asset/",htmlData , "text/html", "utf-8",null);
这样,它将开始直接从 assets 文件夹中获取图像。
关于java - Android - 在 html webview 中添加图像但图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56880286/