Android 开发:在 WebView 的 HTML 中使用来自资产的图像 [英] Android Development: Using Image From Assets In A WebView's HTML
本文介绍了Android 开发:在 WebView 的 HTML 中使用来自资产的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我正在制作一个基本的 HTML 帮助文档.我想在 HTML img 标签本身中包含我的应用程序徽标,但我不知道如何引用将存储在资产中的徽标.
In my app I'm making a basic HTML help document. I wanted my app's logo in the HTML img tag itself, but I don't know how I'd reference to the logo which will be stored in assets.
这可能吗,如果可能,怎么办?
Is this possible, if so how?
感谢您的帮助!
推荐答案
把你的Logo放到assets目录例如:assets/logo.png
Put your Logo into the assets directory eg: assets/logo.png
然后加载您的 html:
Then load your html with:
webView.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "utf-8", null);
像这样引用你的 img:
Reference your img like:
<img src="logo.png">
这篇关于Android 开发:在 WebView 的 HTML 中使用来自资产的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文