Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting webview background image to a resource graphic in Android

As always you tend to figure these things out as soon as you ask the question. For the benefit of others, the layout that I'm using, LinearLayout, can take a background parameter that can be a colour or a resource.

So in my views .xml file I simply added a

android:background="@+drawable/backgroundmain"

and use

web.setBackgroundColor(0);

To make the webview transparent to see the background image behind.


It will work perfectly, if you do something like this:

webView.setBackgroundColor(Color.TRANSPARENT);
webView.setBackgroundResource(R.drawable.your_image);

If not working on Android 3.1, try fix the AndroidManifest.xml:

android:hardwareAccelerated="false"