机器人的WebView无法完全呈现内容,直到用户交互 [英] Android WebView Fails to Completely Render Content Until User Interaction

查看:229
本文介绍了机器人的WebView无法完全呈现内容,直到用户交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义类扩展的WebView显示HTML内容。当用户点击在HTML文档中的链接,余计算的X值滚动到,然后使用scrollTo(X,Y),以显示通过一个可运行的该位置(见下文)

I have a custom class extending WebView that displays HTML content. When the user clicks a link in the HTML document, I calculate an X value to scroll to, and then use scrollTo(x,y) to show that location via a runnable (see below)

 post( new Runnable() {

            @Override
            public void run() {

                scrollTo( x, 0 );
                MyWebView.this.invalidate();
                MyWebView.this.buildDrawingCache();
                MyWebView.this.refreshDrawableState();
                MyWebView.this.postInvalidate();
            }
        } );

滚动之后,有机会的web视图将无法使整个文档。空白矩形块,每次都示出了其中的文字应该是,看似随意的放置。下面是截图: http://i.imgur.com/g192Y.jpg

在我接触到的WebView滚动,就会立刻呈现缺失的部分。

When I touch the webview to scroll, it will immediately render the missing portions.

到目前为止,这种行为被限制在三星Galaxy 10.1平板电脑。

So far this behavior is constrained to the Samsung Galaxy 10.1" tablet.

有谁知道一个解决方法/如何强制WebKit的重新渲染的页面?

Does anyone know a workaround / how to force webkit to re-render the page?

推荐答案

好吧,我在这里有与平板电脑完全一样​​的问题,唯一的区别是,我使用的iscroll 即可完成所有的滚动。我使用这个问题的解决方案是滚动通过JavaScript一个隐藏的DIV,并且解决了这一问题。我希望这可以帮助任何人以同样的问题。如果您使用iscroll他们有一个方法,滚动到一个固定的位置,也许可以帮助你还,如果没有是不是很难检测到的 touchmove 鼠标移动事件。 这里的关键是,你只需要假滚动的HTML的任何地方,即使是不可见的。

Well i am having the exact same problem here with that tablet, the only difference is that i am using iscroll to do all the scrolling. The solution i am using for this problem is to "scroll" via JavaScript a hidden DIV and that fixed the problem. i hope this can help anyone with the same problem. If you use iscroll they have a method to "scroll" to a fixed position, maybe that can help you also, if not is not that hard to detect the touchmove or mousemove events. The point here is that you just need to fake a scroll anywhere on the html even if is not visible.

这篇关于机器人的WebView无法完全呈现内容,直到用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆