【发布时间】:2015-06-29 16:12:04
【问题描述】:
我是安卓开发新手。 我正在使用 webview 在 android 中显示 HTML 页面,但只显示文本。 你能帮我解决这个问题吗? 提前谢谢你,会很有帮助的。
WebView view = (WebView) this.findViewById(R.id.webView);
try{
InputStream stream = this.getAssets().open("Capacitor Code Calculator.html");
int streamsize = stream.available();
byte[] buffer = new byte[streamsize];
stream.read(buffer);
stream.close();
String html = new String(buffer);
view.loadData(html,"text/html", "utf-8");
}
catch (Exception e){
e.printStackTrace();
是否必须对 view.loadData(html,"text/html", "utf-8"); 中的 "text/html" 做一些事情?
我的 html 和图片文件都在 assets 文件夹中。
【问题讨论】:
标签: android html image android-webview