我正在寻找一块代码,它能够在版本4.0及以上的WebView
中获得透明背景。我的代码在2.3版本上运行正常,但在4.0和4.2版本上运行时,它的白色背景已经变成白色。我正在提供适用于版本2.3的代码,但不在4.0和4.2中。请帮帮我。在此先感谢...如何获得webView的4.0版本的透明背景
在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"
/>
在活动文件:
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. */
我试过这一次,但最终我对WebView和应用程序使用了相同的背景,所以出现了一个幻觉,它是透明的。 – vorrtex 2013-03-21 15:26:03