Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android上WebView中的透明PNG_Android_Webview_Png - Fatal编程技术网

Android上WebView中的透明PNG

Android上WebView中的透明PNG,android,webview,png,Android,Webview,Png,我有一些带有透明背景的PNG文件,我想放在一个网页中,在Android WebView中查看。WebView设置为以图像为背景。我注意到,比如说,谷歌chrome,甚至在手机上都可以使用透明功能,但在我的网络视图中,这些图像的背景是白色的。以下是页面的标记: <div id="image_container"> <img src="teststicker1.png" style="background-color:transparent;" /> <

我有一些带有透明背景的PNG文件,我想放在一个网页中,在Android WebView中查看。WebView设置为以图像为背景。我注意到,比如说,谷歌chrome,甚至在手机上都可以使用透明功能,但在我的网络视图中,这些图像的背景是白色的。以下是页面的标记:

<div id="image_container">
    <img src="teststicker1.png" style="background-color:transparent;"  />
    <img src="teststicker2.png" style="background-color:transparent;" />
    <img src="teststicker3.png" style="background-color:transparent;"/>
    <img src="teststicker4.png" style="background-color:transparent;"/>
</div>

在Web视图上加载内容后使用以下方法将Web视图的背景色设置为透明:

yourWebView.setBackgroundColor(Color.TRANSPARENT);
每次在代码中创建web视图后清除缓存,以避免加载缓存页面。(从我下面的评论中得出这一点)

使用以下命令:
setBackgroundColor(Color.TRANSPARENT)

如果你能解释一下否决票的原因,我将不胜感激。对不起,我无意中接受了你的回答。我以后可能会接受,但我还没有试过。谢谢.myWebView.loadUrl(getActivity().getResources().getString(R.string.site_url)+getActivity().getResources().getString(R.string.image_picker_html));myWebView.setBackgroundResource(R.drawable.image_gallery_2_2);setBackgroundColor(Color.TRANSPARENT);仍然显示白色背景。页面本身有一个透明的背景,但没有图像。is
myWebView.setBackgroundResource(R.drawable.image\u gallery\u 2\u 2)必需?这是什么?它是白色背景吗?它是绿色的,有一些渐变。可绘制的图片在图片周围可见,但在图片的透明背景中不可见。您能否在问题中添加您看到的内容和上述代码的屏幕截图?有了格式,阅读起来会更容易。
yourWebView.setBackgroundColor(Color.TRANSPARENT);
yourWebView.clearCache(true);