webview的loaddata()在将HTML代码作为String提供时不显示图像?

时间:2014-01-20 09:25:40

标签: android html webview

Webview wv=(WebView)findViewById(R.id.webview1);
``String str="<html>
            <body>
            <img src='file:///android_asset/nag.png' height='300' width='200'/>
            </body>
            </html>";
wv.loadData(str,"text/html","UTF-8");

1 个答案:

答案 0 :(得分:0)

尝试使用此代码

wv.loadDataWithBaseURL("file:///android_asset/", str, "text/html", "UTF-8",null);

而不是

wv.loadData(str,"text/html","UTF-8");