您的位置:首页 > 移动开发 > Android开发

android WebView渲染html

2015-01-20 14:39 295 查看
xml文件中:

<WebView

android:id="@+id/wv"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="@string/hello"/>

java文件中:

WebView
webView= (WebView) this.findViewById(R.id.wv);

//要解析的HTML字符串

final String htmlText = "<html>" +

"<head></head>" +

"<body>" +

"<br/>" +

"<table align="center" border="0" cellspacing="15">" +

"<tr align="center"><td><img src="file:///android_asset/edict.png" /></td>" +

"<td>" +

"<b><font size="5">" + vStr +"</font></b><br/>" + vNum +

"</td></tr>" +

"</table>" +

"         " +

"</body></html>";

//最后一击!

webView.loadDataWithBaseURL("about:blank",
htmlText, "text/html", "utf-8", null);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: