安卓:ListView.getScrollY() - 它的工作原理?它的、工作原理、ListView、getScrollY

2023-09-12 06:36:42 作者:绕指柔情

我使用它,但它总是返回0,尽管我已滚动到列表的末尾。

I am using it, but it always returns 0, even though I have scrolled till the end of the list.

推荐答案

getScrollY()实际上是一个方法的视图,而不是ListView控件。它指的是整个视图的滚动量,所以它几乎总是0

getScrollY() is actually a method on View, not ListView. It is referring to the scroll amount of the entire view, so it will almost always be 0.

如果你想知道多远ListView控件的内容滚动,你可以使用listView.getFirstVisiblePosition();

If you want to know how far the ListView's contents are scrolled, you can use listView.getFirstVisiblePosition();