我有一个WebView(Android 3.0+)的问题,WebView在显示我的黑色背景("闪烁")之前总是显示白色背景.这是我简单的测试代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
webView.setBackgroundColor(Color.BLACK);
setContentView(webView);
loadWebView(webView);
webView.loadDataWithBaseURL("localhost://", "<html><head>" +
"<style>body {background-color: #000}img{max-width:100%}</style></head>" +
"<body>" +
"<img src=\"http://developer.android.com/images/practices/actionbar-phone-splitaction.png\" />" +
"</body></html>",
"text/html", "UTF-8", null);
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多解决方案来摆脱这个问题,但并不幸运.
PS:如果关闭硬件加速,则不会出现此问题.有人有同样的问题并解决了吗?
谢谢.
android webview hardware-acceleration android-3.0-honeycomb android-4.0-ice-cream-sandwich