我正在尝试将存储在数据库中的包含图像的 html 字符串加载到 WebView
中。图像存储在内部存储器中。我正在提供对 html 字符串的引用。但它不起作用。有帮助吗?
String content="<p>Can we have a rotational" +
" symmetry of order more than 1 whose angle of rotation is </p>\n" +
"\n <p>(i) <img alt=\"45\\degree\" src=\"file:///storage/emulated/01484890695248.jpg\" /></p>\n" +
"\n<p>(ii) <img alt=\"35\\degree\" src=\"file:///storage/emulated/01484890697301.jpg\" /></p>";
WebView00.loadDataWithBaseURL("", content, "text/html","UTF-8", "");
WebView00.getSettings();
最佳答案
这样试试
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://"+ base + "/image_name.jpg";
String html = "<html><head></head><body> <img src=\""+ imagePath + "\"> </body></html>";
webView.loadDataWithBaseURL("", html, "text/html","utf-8", "");
关于android - Android WebView加载本 map 片的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42266264/