WebView getScrollY()始终返回0 [英] WebView getScrollY() always returns 0

查看:512
本文介绍了WebView getScrollY()始终返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用网络视图的滚动位置来确定SwipeRefreshLayout是否应该能够刷新,除了某些网站(例如 https://jobs.lever.co/memebox ,getScrollY()始终返回0.有没有办法确保我将始终获得正确的滚动位置?

Im trying to use the webview's scroll position to determine whether SwipeRefreshLayout should be able to refresh, except for some websites e.g. https://jobs.lever.co/memebox, getScrollY() always returns 0. Is there a way to ensure I will always get the correct scroll position?

推荐答案

您链接的网站具有固定的标头.我的猜测是页面本身不会滚动.里面有一个容器. WebView无法检查页面上的每个可滚动容器,因此它会发现顶级容器不会滚动,并假定整个容器都是固定的.

The site you linked has a fixed header. My guess is that the page itself doesn't scroll; a container inside it does. The WebView can't inspect every scrollable container on the page, so it sees that the top-level container doesn't scroll and assumes that the entire thing is fixed.

如果您需要的只是拉动刷新,我建议在SwipeRefreshLayout之外再添加一个刷新按钮.

If all you need this for is pull-to-refresh, I'd recommend adding a refresh button in addition to the SwipeRefreshLayout.

这篇关于WebView getScrollY()始终返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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