Android HTML resource with references to other resources

孤人 提交于 2019-12-19 03:43:11

问题


I would like to add an HTML resource to my Android project with references to other resources (mainly drawables).

Where should I put it and how do I reference other resources from it?

Is there a particular way to pass the HTML resource to a WebView?

Thanks!


回答1:


The html file goes into the assets folder in root (as a sibling folder of res), as well as all the drawables. You can view it by doing something like

webView.loadUrl("file:///android_asset/filename.html");



回答2:


If your file is on the SD card, this reference will work:

content://com.android.htmlfileprovider/sdcard/filename.jpg



来源:https://stackoverflow.com/questions/3295381/android-html-resource-with-references-to-other-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!