简体   繁体   English

无法在android webview中加载本地图像

[英]Unable to load local images in android webview

i am trying to load local images in android webview by using assets folder, but when i tries to open it, it is loading only HTML but not images 我正在尝试使用资产文件夹在android webview中加载本地图像,但是当我尝试打开它时,它仅加载HTML而不加载图像

In my HTML Code i have added following line 在我的HTML代码中,我添加了以下行

<IMG SRC="file:///android_asset/images/a.jpg">

But it is not displaying image, can anybody please help? 但是它没有显示图像,有人可以帮忙吗?

通过创建单独的图像文件夹(例如assets/images将图像放入资源文件夹中,然后在html页面中提供图像的路径为

  <IMG src="images/test.png"> 

first of which url loading in webview, is it local url or http (means requires internet). 首先,在Webview中加载的是本地url还是http(意味着需要互联网)。 If ur loading local file system url pealse check the image path properly, it should work. 如果您在加载本地文件系统url时检查图像路径正确,则应该可以。 if loading http url trying load a local images inside it sorry its not possible. 如果加载http url尝试加载其中的本地图像,将对不起。 Here its cross domain issue will restrict to that. 在这里,它的跨域问题将限于此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM