有时候,当我打开我的WebView与使用loadURL,该网站没有显示出来,直到我触摸屏幕或滚动。
Sometimes, when I load my webview with loadUrl, the website is not showing up until I touch the screen or scroll.
这就像我有一个web视图绘制的问题。
It's like I have a webview drawing problem.
Context context = ctx;
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.website);
WebView webView = (WebView) dialog.findViewById(R.id.weburl);
webView.setScrollbarFadingEnabled(false);
//Disable the horizontal scroll bar
webView.setHorizontalScrollBarEnabled(false);
//Enable JavaScript
webView.getSettings().setJavaScriptEnabled(true);
//Set the user agent
webView.getSettings().setUserAgentString("AndroidWebView");
//Clear the cache
webView.clearCache(true);
webView.loadUrl("http://" + WebUrl);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
// do your handling codes here, which url is the requested url
// probably you need to open that url rather than redirect:
view.loadUrl(url);
view.setVisibility(View.VISIBLE);
return false; // then it is not handled by default action
}
@Override
public void onPageFinished(WebView view, String url) {
view.refreshDrawableState();
Log.v("FINISH","FINISH");
}
});
不要任何人有一个想法,为什么我有这样的问题。
Do anybody have an idea why I have this kind of problem.
您测试的是什么版本的Android? pre-4.1版本的Android似乎有这种问题WebViews的时候。
What version of Android are you testing on? Pre-4.1 versions of Android seem to have this sort problem with WebViews sometimes.
这添加到该清单为活动来解决这个问题:
Add this to the manifest for that Activity to fix the problem:
android:hardwareAccelerated="false"