Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getScrollY StaggerGridView return 0 #194

Open
amaydiam opened this issue Jul 25, 2015 · 0 comments
Open

getScrollY StaggerGridView return 0 #194

amaydiam opened this issue Jul 25, 2015 · 0 comments

Comments

@amaydiam
Copy link

I'm using Android-ParallaxHeaderViewPager and StaggeredGridView to create layout like pinterest. I getting problem when getScrollY, the result is sometimes return 0 when scroll at central position on the first row gird , Where first row grid with 2 column/items and different height each items.

imaging :
enter image description here

this the code :

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
                         int visibleItemCount, int totalItemCount, int pagePosition) {
        if (mViewPager.getCurrentItem() == pagePosition && visibleItemCount > 0) {
            int scrollY = getScrollY(view); // sometimes return 0, when scroll at central position on the first row .
        }
    }


 public int getScrollY(AbsListView view) {
        View c = view.getChildAt(0);
        if (c == null) {
            return 0;
        }

        int firstVisiblePosition = view.getFirstVisiblePosition();
        int top = c.getTop();

        int headerHeight = 0;
        if (firstVisiblePosition >= 1) {
            headerHeight = mHeaderHeight;
        }

        return -top + firstVisiblePosition * c.getHeight() + headerHeight;
    }

so how to fix it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant