Nam*_*und 4 android image webview
我正在尝试将包含图像的数据库中存储的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();
Run Code Online (Sandbox Code Playgroud)
Cha*_*ruක 11
试试这样吧
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", "");
Run Code Online (Sandbox Code Playgroud)