Skip to content

The value in getScrollY() method #27

@machinezhou

Description

@machinezhou

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions