设置背景图片为Android的网页视图 [英] Set a background image for a webview in Android

查看:280
本文介绍了设置背景图片为Android的网页视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个背景图像中的Andr​​oid网页视图。
我做了以下内容:

  webView.setBackgroundColor(0);
webView.setBackgroundResource(R.drawable.backgroundImage);

我想要的图像是在网页视图的中间。任何帮助吗?

修改
我已经找到了解决办法:

  linearLayout.setGravity(Gravity.CENTER);
imageView.setBackgroundResource(R.drawable.backgroundImage);
linearLayout.addView(ImageView的);
frameLayout.addView(LinearLayout中);
frameLayout.addView(web视图);


解决方案

这下面正常工作对我来说 -

 的WebView myWebView =(的WebView)findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor(#000000));

I want to set a background image for a webview in android. I did the following:

webView.setBackgroundColor(0);
webView.setBackgroundResource(R.drawable.backgroundImage);

I want the image to be in the middle of the webview. Any help please?

EDIT I have found the solution:

linearLayout.setGravity(Gravity.CENTER);
imageView.setBackgroundResource(R.drawable.backgroundImage);
linearLayout.addView(imageView);
frameLayout.addView(linearLayout);
frameLayout.addView(webView);

解决方案

This below normally works for me -

WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor("#000000"));

这篇关于设置背景图片为Android的网页视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆