Android WebView style background-color:transparent ignored on android 2.2

jptsetung picture jptsetung · Feb 15, 2011 · Viewed 123.8k times · Source

I'm struggling to create a WebView with transparent background.

webView.setBackgroundColor(0x00FFFFFF);
webView.setBackgroundDrawable(myDrawable);

Then I load a html page with

<body style="background-color:transparent;" ...

The background color of the WebView is transparent but as soon as the page is loaded, it's overwritten by a black background from the html page. This only happens on android 2.2, it works on android 2.1.

So is there something to add in the html page code to make it really transparent ?

Answer

scottyab picture scottyab · May 5, 2011

This worked for me,

mWebView.setBackgroundColor(Color.TRANSPARENT);