小编Tap*_*esh的帖子

如何获得webView for 4.0版本的透明背景

我正在寻找一段能够在WebView版本4.0及更高版本中获得透明背景的代码.我的代码在2.3版本上运行良好,但是当我在4.0和4.2版本上运行时,它获得了白色背景.我提供的代码适用于2.3版,但不适用于4.0和4.2版.请帮我.提前致谢...

在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"        
    />
Run Code Online (Sandbox Code Playgroud)

在活动文件中:

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. */
Run Code Online (Sandbox Code Playgroud)

android webview

21
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

webview ×1