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

Listitems of variable size? #15

Open
thevarun opened this issue Dec 12, 2014 · 6 comments
Open

Listitems of variable size? #15

thevarun opened this issue Dec 12, 2014 · 6 comments

Comments

@thevarun
Copy link

Will this work properly if the row elements in the listview are of different sizes?
The way getScrollY (on the basis of which Header is animated) is implemented, it looks as though scrolling will be smooth only if all elements are of equal size. Kindly correct me if I am wrong.

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;
}
@yolapop
Copy link

yolapop commented Jan 12, 2015

I think I just got the problem that you described, do you know the workaround?

@thevarun
Copy link
Author

No, I am waiting for a resolution of this issue before using the library myself.

@xifan-xf
Copy link

i use staggergridview and the item are different sizes
this is my solution:

    mMinHeaderHeight = mHeaderHeight - mTabsHeight;
    mMinHeaderTranslation = -mMinHeaderHeight;
public int getScrollY(StaggeredGridView view, int pagePosition) {
    View c = view.getChildAt(0);
    if (c == null) {
        return 0;
    }
    int firstVisiblePosition = view.getFirstVisiblePosition();
    View headView = ((PLA_ListView) view).getHeaderView();
    if (Math.abs(ViewHelper.getTranslationY(mHeader)) == mMinHeaderHeight) {
        if (headView != null && headView.getTop() <= mMinHeaderTranslation) {
            return -mMinHeaderTranslation;
        }
    }
    int top = c.getTop();
    int headerHeight = 0;
    if (firstVisiblePosition >= 1) {
        headerHeight = mHeaderHeight;
    }

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

@yolapop
Copy link

yolapop commented Jan 14, 2015

Thank you @XUFAN your solution worked. One thing that I have to be careful is to detect user scroll because if the adapter changes it will call onScroll too.

@yolapop
Copy link

yolapop commented Jan 14, 2015

Turns out it still doing the uneven scroll when changing tabs. Did you make any change on the ScrollTabHolderFragment's adjustScroll?

@xifan-xf
Copy link

@yolapop if you use something like StaggeredGridView,PLA_ListView .it don't implement smoothScrollToPositionFromTop or setSelectionFromTop method . so when changing tabs it won't work well. as far as i know ,in this lib only can use listview,scrollview&HeaderFooterGridView .

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

3 participants