我正在寻找一段能够在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"
/>
在活动文件中:
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. */