ViewPager 或 ScrollView 中的 WebView - Android 3.0 上奇怪的渲染错误
我有一个 ViewPager。 ViewPager的每一页都是一个ScrollView。 ScrollView 包含一个 WebView 和几个其他视图。
在 Android 2.3 及更早版本上,一切正常,但在 3.0+ 上,存在一个奇怪的渲染问题:
在 ViewPager 中向左/向右滚动时,还存在一个非常微妙的渲染问题(Android 4.0 Gmail 应用程序中也存在该问题)。
I have a ViewPager. Every page of the ViewPager is a ScrollView. The ScrollView contains a WebView and several other Views.
On Android 2.3 and older everything works fine but on 3.0+ there's a weird rendering issue:
When scrolling left / right in the ViewPager, there is also a very subtle rendering issue (which is present in Android 4.0 Gmail app too).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能与硬件加速有关。尝试专门将其关闭。您可以执行此操作
1) 在清单内的应用程序标记中(这将禁用整个应用程序的硬件加速)
或 2) 在代码中为有问题的视图禁用它:
了解更多信息,并检查 WebView 或 ListView 是否处理硬件加速正确请参阅此链接
This might be related to hardwareAcceleration. Try specifically turning it off. You can do this
1) in the application tag inside your manifest (which will disable hardware acceleration throughout the app)
OR 2) Disabling it for the problematic view in code:
For more information, and to check if a WebView or a ListView handle hardware acceleration correct see this link
我通过在
ScrollView.onScrollChanged()
中调用webView.requestLayout()
部分解决了这个问题。现在几乎可以了,但是当滚动时,WebView
似乎与其他ScrollView
子项稍微不同步。有时,WebView
的滚动速度似乎比其他视图稍微慢一些,稍后就会赶上它们。I partially solved it by calling
webView.requestLayout()
inScrollView.onScrollChanged()
. It is now almost ok, but when scrolling, theWebView
seems slightly out of sync with otherScrollView
children. Sometimes theWebView
seems to scroll slightly slowly than other Views and catches up with them a moment later.有同样的问题,但接受的答案没有解决。最后发现和页面CSS中的
position:fixed
有关。用position:absolute
替换这些实例似乎已经成功了。Had the same issue that wasn't fixed by the accepted answer. In the end, it turned out to be related to
position:fixed
in the page's CSS. Replacing these instances withposition:absolute
seems to have done the trick.