我想要一个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.
上一篇:如何在Android的谷歌地图V2上标记的自定义信息窗口进行点击操作自定义、标记、窗口、操作
下一篇:获取无效android_key参数错误,第一次登录Facebook的Android SDK中后错误、参数、android_key、Facebook