I want to display webView on static image on imageView.
I set transparent color to webView like this
webview.setBackground(0);
I set background-color as transparent
<html>
<head>
</head>
<body style="background-color:transparent">
</body>
</html>
but Webview's background keep displaying as white.
I show any questions and try these following page's solution but nothing to change.
Do you have any ideas? Please help me.
I ran into the same problem with the white WebView background on a device with ICS (4.0)!
The answer from NcJlee did remove the white background from the webview, but it requires API level 11! It will not work on older API's!
webView.setBackgroundColor(0);
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
The solution is to set a android:layerType="software" attribute on the webview in the .xml layout resource.
<WebView
android:id="@+id/webviev"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:layerType="software" />
One way to avoid this is to uncheck "Force GPU Rendering" in
Settings -> Developer Options -> Force GPU Rendering
But that doesn't solve the problem. I've tried this code in emulator and it works. By forcing the webview to render by using software instead of hardware acceleration.
webview.setBackgroundColor(Color.TRANSPARENT);
webview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
Does it solve your problem?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With