3 回答

TA貢獻1878條經驗 獲得超4個贊
我在2.2和2.3中都有相同的問題。我通過在html中而不是在android中提供alpa值解決了問題。我嘗試了很多事情,發現setBackgroundColor();顏色不能與alpha值一起使用。webView.setBackgroundColor(Color.argb(128, 0, 0, 0));不管用。
所以這是我的解決方案,為我工作。
String webData = StringHelper.addSlashes("<!DOCTYPE html><head> <meta http-equiv=\"Content-Type\" " +
"content=\"text/html; charset=utf-8\"> </head><body><div style=\"background-color: rgba(10,10,10,0.5); " +
"padding: 20px; height: 260px; border-radius: 8px;\"> $$$ Content Goes Here ! $$$ </div> </body></html>");
在Java中
webView = (WebView) findViewById(R.id.webview);
webView.setBackgroundColor(0);
webView.loadData(webData, "text/html", "UTF-8");
- 3 回答
- 0 關注
- 1293 瀏覽
添加回答
舉報