机器人的WebView背景颜色 [英] Android WebView background color

查看:161
本文介绍了机器人的WebView背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加到我的布局的WebView来显示对齐文本。我想设置的WebView的背景是透明的,看起来像一个TextView。这是我做的:

 的WebView简介;
简介=(web视图)findViewById(R.id.synopsis);
synopsis.setBackgroundColor(00000000);
 

它工作在模拟器上,但是当我在我的设备上运行的应用程序也无法正常工作:我所得到的是一个白色背景

 字符串textTitleStyling =< HEAD><风格> * {保证金:0;填充:0;字体大小:20;文本对齐:证明;颜色:#FFFFFF ;}< /样式和GT;< /头>中;
 字符串titleWithStyle = textTitleStyling +<身体GT;< H1>中+ movie.synopsis +< / H1>< /身体GT;;
 synopsis.loadData(textTitleStyling + movie.synopsis,text / html的,UTF-8);
 简介=(web视图)findViewById(R.id.synopsis);
 synopsis.getSettings();
 synopsis.setBackgroundColor(0);
 

解决方案

尝试使用synopsis.getSettings();

 的WebView简介;
简介=(web视图)findViewById(R.id.synopsis);
synopsis.getSettings();
synopsis.setBackgroundColor(00000000);
 

I am adding to my layout a WebView to display justified text. I want to set the background of the WebView to be transparent to appear like a textView. Here's what I did:

WebView synopsis;
synopsis=(WebView)findViewById(R.id.synopsis);
synopsis.setBackgroundColor(0x00000000);

It works on the emulator, but when I run the application on my device it doesn't work: what I get is a white background.

 String textTitleStyling = "<head><style>* {margin:0;padding:0;font-size:20; text-align:justify; color:#FFFFFF;}</style></head>";
 String titleWithStyle = textTitleStyling + "<body><h1>" + movie.synopsis + "</h1></body>";
 synopsis.loadData(textTitleStyling + movie.synopsis, "text/html", "utf-8");
 synopsis = (WebView) findViewById(R.id.synopsis);
 synopsis.getSettings();
 synopsis.setBackgroundColor(0);

解决方案

Try using synopsis.getSettings();

WebView synopsis;
synopsis=(WebView)findViewById(R.id.synopsis);
synopsis.getSettings();
synopsis.setBackgroundColor(0x00000000);

这篇关于机器人的WebView背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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