简体   繁体   English

WebView如何获取本地res \\ drawable-hdpi图像路径

[英]WebView how to get local res\drawable-hdpi image path

I have a WebView and I want to add a backgroung Image 我有一个WebView,我想添加一个背景图像

String htmlPage = "<HTML><BODY background=\"bgrnd.png\" TEXT=\"black\">";

the problem is how to get the image path "bgrnd.png" which is saved in res"\\drawable-hdpi" folder. 问题是如何获取保存在res“ \\ drawable-hdpi”文件夹中的图像路径“ bgrnd.png”。

Thx. 谢谢。

将您的图片放入素材资源文件夹,您可以像这样将其用于图片标签

<img src="file:///android_asset/images/yourimage.png">

In xml use 在xml中使用

android:background="@+drawable/bgrnd.png"

Set mWebView.setBackgroundColor(0); 设置mWebView.setBackgroundColor(0); below your string 在你的弦下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 资源问题:如何获取 res/drawable-hdpi 文件夹的标识符? - Android resources problem: How to getIdentifier for a res/drawable-hdpi folder? 如何打开JPG文件作为保存在…/ res / drawable-hdpi /中的BITMAP? - How to open a JPG file as a BITMAP stored on the …/res/drawable-hdpi/? 如何获取保存在res / drawable-hdpi文件夹中的jpg的ID? - How can one get the ID of a jpg saved in res/drawable-hdpi folder? 如何使用res文件夹的drawable-hdpi,drawable-mdpi,drawable-ldpi中存在的图像? - how to use images present in drawable-hdpi,drawable-mdpi,drawable-ldpi of res folder? Android:如何在drawable-hdpi中放置具有不同分辨率的相同图像 - Android: how to place same image with different resoultion in drawable-hdpi 单击按钮时,从库中的res / drawable-hdpi打开图像 - Open image from res/drawable-hdpi in gallery when clicking a button 以hdpi分辨率为图像命名drawable-hdpi重要吗? - is it important to name drawable-hdpi for image in hdpi resolution? 如何同时使用可绘制和可绘制hdpi中的资源? - how to use resources from drawable and drawable-hdpi at the same time? 图像大小(drawable-hdpi/ldpi/mdpi/xhdpi) - image size (drawable-hdpi/ldpi/mdpi/xhdpi) 我想将我的animation.zip文件解压缩到res / drawable-hdpi - I want to unzip my animation.zip file in to the res/drawable-hdpi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM