我创建了一个具有透明背景的 webview。
browser = new WebView(ActivityActivate.this);
browser.setBackgroundColor(0);
browser.getSettings().setJavaScriptEnabled(true);
browser.addJavascriptInterface(new JavascriptInterface(), "javaInterface");
browser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
browser.getSettings().setSupportZoom(true);
browser.loadDataWithBaseURL("https://checkout.google.com", form, "text/html", "UTF-8", null);
llPaymentButtons.addView(browser);
这是在提交 html 表单并且所有复选框都通过测试时应该更改背景颜色的 JavaInterface。
/**
* Interface for Javascript communication
*/
private class JavascriptInterface {
//This is in fact used but from JavaScript
@SuppressWarnings("unused")
public boolean checkboxPass() {
if( acceptsConditions() && acceptsLicense() && acceptsRefundPolicy() ) {
browser.setBackgroundColor(Color.WHITE);
return true;
}
return false;
}
}
但是,这不起作用,返回的文档仍然具有透明背景。我做错了什么,似乎browser.setBackgroundColor(Color.WHITE);
什么也没做?