【问题标题】:webview's loaddata() not displaying the image when supply html code as String?将 html 代码作为字符串提供时,webview 的 loaddata() 不显示图像?
【发布时间】:2014-01-20 09:25:39
【问题描述】:
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");

【问题讨论】:

  • 在我的答案中使用 BaseURL 给定代码加载 webview

标签: android html webview


【解决方案1】:

尝试使用此代码

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

代替

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

【讨论】:

  • 六年前,但仍然像魅力一样工作。谢谢!
  • "file:///android_asset/" 从来不知道从字符串加载 URL 需要这样
猜你喜欢
  • 1970-01-01
  • 2018-08-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-05
  • 1970-01-01
  • 2014-10-14
  • 1970-01-01
相关资源
最近更新 更多