@android显示/ RES /可视的web视图 [英] @Android display /res/viewable in WebView

查看:156
本文介绍了@android显示/ RES /可视的web视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我扔HTML到web视图渲染。在HTML我需要加载,我在一个图像 / RES /绘制

I am throwing HTML to a webview to render. In the HTML I need to load an image that I have in /res/drawable.

我有 /res/drawable/my_image.png 和code像这样的:

I have /res/drawable/my_image.png and code such as this:

final WebView browser = (WebView) findViewById(R.id.my_webview);
String html = new MyHelper(myObject).getHtml();
browser.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");

其中字符串 HTML 有这样的:

<html><head>
<h1>Here is the image</h1>
<img src="my_image.png" />
</head><html>

现在的问题是,什么应该是像的src 属性是指图像中的 / RES /绘制

The question is, what should that image src attribute be to refer to the image in /res/drawable?

推荐答案

这曾在安卓2.2

<img src = "file:///android_res/drawable/q1.png" />

在这里q1.png是在res /绘制,华电国际文件夹

where q1.png is in the res/drawable-hdpi folder

这篇关于@android显示/ RES /可视的web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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