是否有可能在Android的loadDataWithBaseURL()方法显示图像? [英] Is it possible to display image with loadDataWithBaseURL() method in android?

查看:881
本文介绍了是否有可能在Android的loadDataWithBaseURL()方法显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图显示与<一个HTML文件的内容href="http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29"相对=nofollow> loadDataWithBaseURL()方法机器人。

I'm trying to display the content of a html file with the loadDataWithBaseURL() method in android.

我只是有一个包含在一个字符串中的HTML文件的数据称为源,然后我把它传递给方法的字符串。

I just have a String that contains the Html file data in one String called source and I then pass this to the method.

对于例如

String source; //contain html tags with images
View.loadDataWithBaseURl(null,source,"text/html","UTF-8","about:blank");

在视图中显示的数据是好的。 我的问题是,如果我的HTML文件包含的任何图像,然后我可以不显示呢? 我该怎么办呢?

The data displayed in view is fine. My problem is if my html file contains any images then I couldn't displayed it? how can I do that?

推荐答案

你可以做到这一点,如果源中的图像用于SRC的相对位置,那么你需要的的baseUrl设置为基地里的图像将设。例如,如果你从源加载谷歌的主页,它是这样的:

you can do it, if the images in the source use relative locations for the src then you need to set the baseUrl to the "base" of where the images would be located. for example, if you were loading google's home page from the source, it would look like this:

View.loadDataWithBaseURI("http://google.com",source,"text/html","UTF-8","about:blank");

这告诉那里的图像将被从加载web视图。

That tells the webview where the images will be loaded from.

作为一个方面说明,我不认为文件://URI的作品在网络视图中,出于安全原因,

As a side note, I do not think "file://" URIs works in the web view, for security reasons.

这篇关于是否有可能在Android的loadDataWithBaseURL()方法显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆