Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove the white background in a webview?

I have the following problem: I am loading a html file into a webview. The background color of my html file and my activity is black. What happens is that there is a short white flash at the beginning when finished loading because the background color of the webview is white.

Can I remove that flash? Or set that webview color to black? I already tried setting the background color in the webview xml to black, but it didn't work.

like image 893
user1420042 Avatar asked Sep 20 '12 20:09

user1420042


2 Answers

I had the same problem and this solved it for me:

Just below the existing

mWebView = (WebView) findViewById(R.id.activity_main_webview);

I added the line

mWebView.setBackgroundColor(Color.BLACK);

To do any good it must be before

mWebView.loadUrl(...)
like image 36
joel.schopp Avatar answered Oct 08 '22 18:10

joel.schopp


Yes you can. Try:

webview.setBackgroundResource(Color.Black);
like image 114
Samer Avatar answered Oct 08 '22 19:10

Samer