web视图设置背景图片在Android的资源图形 [英] Setting webview background image to a resource graphic in Android
本文介绍了web视图设置背景图片在Android的资源图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个web视图的背景设置为Android的一个绘制的图像资源。
I'm trying to set the background of a webview to a drawable image resource in Android.
从SDK似乎像这样的工作,但事实并非如此。
From the sdk it seems something like this would work but it doesn't.
WebView web = (WebView) findViewById(R.id.webView);
web.setBackgroundResource(R.drawable.backgroundmain);
web.loadData(profile, "text/html", "UTF-8");
任何想法的?
Any idea's?
推荐答案
往常一样,你往往会计算这些东西,只要你问的问题。为他人谋取利益,我使用,的LinearLayout布局,可以采取背景的参数,可以是彩色或资源。
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.
所以,我的观点.xml文件,我只是增加了一个
So in my views .xml file I simply added a
android:background="@+drawable/backgroundmain"
和使用
web.setBackgroundColor(0);
要做出的WebView透明的看到后面的背景图像。
To make the webview transparent to see the background image behind.
这篇关于web视图设置背景图片在Android的资源图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文