【发布时间】:2012-10-04 12:44:10
【问题描述】:
我正在尝试检测列表视图何时滚动超过以像素为单位的某个固定阈值(第一项的一半)。不幸的是,listview 的 getScrollY() 似乎总是返回 0 而不是滚动位置。有没有办法按像素获取实际的滚动位置?
这是我尝试使用的代码,但如前所述,它只返回 0。
getListView().setOnScrollListener(new AbsListView.OnScrollListener() {
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.d("scroll", "scroll: " + getListView().getScrollY());
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == 0)
Log.d("scroll", "scrolling stopped");
}
});
【问题讨论】:
-
正确的solution
标签: android listview scroll scroll-offset