Transparent Backgrounds on Android Views

Transparent Backgrounds on Android Views

A frequent question encountered when using WebView inside of an Android app is “how do I make the background transparent, rather than the default white color?

This is ridiculously easy:

WebView myWebView = new WebView(this);
myWebView.setBackgroundColor(0);


Happy Coding.

Advertisements

2 thoughts on “Transparent Backgrounds on Android Views

  1. Yeah, this works until you use JavaScript to show/hide a div, or do something else dynamic. The WebView doesn’t clear it’s canvas before drawing to it again, so you get terrible artifacts.

    Like

    1. I’m facing exactly the problem you described 😦
      Did you find any workarounds for WebView with transparent background not redrawing correctly after JavaScript manipulations?

      Thanks!

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s