gpt4 book ai didi

android - @Android display/res/viewable 在 WebView

转载 作者:IT老高 更新时间:2023-10-28 23:19:00 27 4
gpt4 key购买 nike

我将 HTML 扔到 webview 进行渲染。在 HTML 中,我需要加载 /res/drawable 中的图像。

我有 /res/drawable/my_image.png 和这样的代码:

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/drawable 中的图像?

最佳答案

这在 android 2.2 中有效

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

q1.png 在 res/drawable-hdpi 文件夹中的位置

关于android - @Android display/res/viewable 在 WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2630829/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com