web视图设置背景图片在Android的资源图形视图、背景图片、图形、资源

2023-09-05 06:23:31 作者:闲鱼昵称叫个啥好 闲鱼昵称起什么好听

我想要一个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.

 
精彩推荐
图片推荐