且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

机器人的WebView背景颜色

更新时间:2023-11-18 23:44:10

尝试使用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);