NotBoringActionBar
NotBoringActionBar copied to clipboard
The value in getScrollY() method
hi sir, I've read your blog and code , and it's great. But I got a little problem still bothering me.
public int getScrollY() { View c = mListView.getChildAt(0); if (c == null) { return 0; }
int firstVisiblePosition = mListView.getFirstVisiblePosition();
int top = c.getTop();
int headerHeight = 0;
if (firstVisiblePosition >= 1) {
headerHeight = mPlaceHolderView.getHeight();
}
return -top + firstVisiblePosition * c.getHeight() + headerHeight;
}
I tried to remove the "firstVisiblePosition * c.getHeight()" and it still work well. So I am still confused about the meaning of this statement.
Hi Machinezhou, This function could be modified as follow :
public int getScrollY() {
View c = mListView.getChildAt(0);
if (c == null) {
return 0;
}
int firstVisiblePosition = mListView.getFirstVisiblePosition();
int top = c.getTop();
if (firstVisiblePosition >= 1) {
return mFakeHeader.getHeight();
}
return -top;
}
cause it does not need (firstVisiblePosition * c.geHeight())