如何获得web视图的透明背景的4.0版本 [英] How to get transparent background of webView for 4.0 version

查看:173
本文介绍了如何获得web视图的透明背景的4.0版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一块code,它能够得到一个的WebView 透明背景为4.0及以上版本。我的code是工作的罚款与2.3版本,但它得到一个白色背景,当我在版本4.0和4.2上运行它。我提供我的code这是工作的2.3版本,而不是在4.0和4.2。请帮我。在此先感谢...

在XML中:

 <的WebView
    机器人:ID =@ + ID / web视图
    机器人:layout_marginTop =6DP
    机器人:layout_below =@ + ID /图像
    机器人:layout_width =match_parent
    机器人:layout_height =FILL_PARENT
    机器人:hardwareAccelerated =真
    />
 

在活动文件中:

  web视图=(web视图)findViewById(R.id.webView);
后退按钮=(ImageView的)findViewById(R.id.backButton);
webView.setBackgroundColor(0);
webView.loadUrl(文件:///android_asset/Info.html);
webView.setBackgroundColor(Color.TRANSPARENT);
/ *这是用来在屏幕上加载文件后,使白色的背景。 * /
 

解决方案

试试这个:

  webView.setBackgroundColor(00000000);
 

和删除安卓hardwareAccelerated =真正的
因为这是题外话。

I am looking for a piece of code which is able to get a transparent background in a WebView for version 4.0 and above. My code is working fine with version 2.3 but it is getting a white background when I run it on version 4.0 and 4.2. I am providing my code which is working for version 2.3, but not in 4.0 and 4.2. Please help me. Thanks in advance...

In XML:

<WebView
    android:id="@+id/webView"
    android:layout_marginTop="6dp"
    android:layout_below="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:hardwareAccelerated ="true"        
    />

In activity file:

webView = (WebView) findViewById(R.id.webView);
backButton = (ImageView) findViewById(R.id.backButton);
webView.setBackgroundColor(0);                      
webView.loadUrl("file:///android_asset/Info.html");
webView.setBackgroundColor(Color.TRANSPARENT);  
/* this is used to make the background white after loading the file on screen. */

解决方案

Try this:

webView.setBackgroundColor(0x00000000);

and remove android:hardwareAccelerated ="true"
as that is off-topic.

这篇关于如何获得web视图的透明背景的4.0版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆