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 ?
Use this
Following code work for me, though i have multiple webviews and scrolling between them is bit sluggish.
this will definitely work.. set background in XML with Editbackground. Now that background will be shown
This worked for me. try setting the background color after the data is loaded. for that setWebViewClient on your webview object like:
set the bg after loading the html(from quick tests it seems loading the html resets the bg color.. this is for 2.3).
if you're loading the html from data you already got, just doing a .postDelayed in which you just set the bg(to for example transparent) is enough..
If nothing helps, then most probably you have fixed sized
webView
, change the width and height to wrap_content ormatch_parent
, it should work. That worked for me when I tried to load a Gif.