机器人的WebView呈现出一个白色的页面

编程入门 行业动态 更新时间:2024-10-26 00:19:29
本文介绍了机器人的WebView呈现出一个白色的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有时候,当我打开我的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("" + 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.

推荐答案

您测试的是什么版本的Andr​​oid? pre-4.1版本的Andr​​oid似乎有这种问题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"

更多推荐

机器人的WebView呈现出一个白色的页面

本文发布于:2023-11-06 21:46:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564764.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:呈现出   机器人   白色   页面   WebView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!