Created
December 22, 2015 01:52
-
-
Save brucetoo/bd95e86db9e921684225 to your computer and use it in GitHub Desktop.
listview 监听顶部滚动的距离的方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Dictionary<Integer, Integer> listViewItemHeights = new Hashtable<Integer, Integer>(); | |
private int getListViewScrollY(AbsListView view) { | |
View c = view.getChildAt(0); | |
int scrollY = -c.getTop(); | |
listViewItemHeights.put(view.getFirstVisiblePosition(), c.getHeight()); | |
for (int i = 0; i < view.getFirstVisiblePosition(); ++i) { | |
if (listViewItemHeights.get(i) != null) | |
scrollY += listViewItemHeights.get(i); //顶部消失的所有Item的高度 | |
} | |
return scrollY; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment