onNewPicture() 什么时候被调用?
onNewPicture() 的 文档 仅说明:
通知听众该图片 已改变
我的问题是:图片何时发生更改?
我注意到有些网页会生成数十个 onNewPicture() ,因此显然“图片”在 WebView 上渲染页面的过程中发生了多次变化。
什么使 WebView 图片发生变化?
我还没有看到任何页面生成少于 2 个 onNewPicture() 调用,那么对于任何给定的 HTML 页面,onNewPicture() 是否保证被调用多次?
The documentation for onNewPicture() only says:
Notify the listener that the picture
has changed
My question is: When does the picture change?
I noticed that some web pages generate dozens of onNewPicture(), so obviously the "picture" changes many times in the course of rendering the page on a WebView.
What makes a WebView picture change?
I haven't seen any page page that generates less than 2 onNewPicture() calls, so is onNewPicture() guaranteed to be called more than once, for any given HTML page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每当已加载的页面完成渲染(或在某些事件使 WebKit 引擎重新计算页面布局时重新渲染)时,都会调用 PictureListener.onNewPicture() 。这实际上取决于正在加载的页面:
一个简单的纯文本页面只会呈现一次。其他页面(尤其是 JavaScript 密集型页面)可以在页面完成加载后被调用多次。
@littleFluffyKitty 的提示位于 另一篇文章:如今,当您在页面上移动时,许多网页都会导致它被频繁调用,因此请确保
onNewPicture()
方法中发生的任何事情都很快。PictureListener.onNewPicture()
is called whenever the already loaded page finished rendering (or re-rendering in case certain events make the WebKit engine re-calculate page layout). It really depends on the page being loaded:A simple text-only page will be rendered only once. Other pages (especially Javascript-heavy ones) can be called numerous times after the page finished loading.
Tip by @littleFluffyKitty found in another posting: Many webpages today will cause it to get called fairly often as you move around the page so make sure whatever happens in the
onNewPicture()
method is quick.