Android-ParallaxHeaderViewPager icon indicating copy to clipboard operation
Android-ParallaxHeaderViewPager copied to clipboard

Listitems of variable size?

Open thevarun opened this issue 10 years ago • 6 comments

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;
}

thevarun avatar Dec 12 '14 15:12 thevarun

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

yolapop avatar Jan 12 '15 16:01 yolapop

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

thevarun avatar Jan 13 '15 08:01 thevarun

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;
}

xifan-xf avatar Jan 14 '15 02:01 xifan-xf

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 avatar Jan 14 '15 04:01 yolapop

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

yolapop avatar Jan 14 '15 04:01 yolapop

@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 .

xifan-xf avatar Jan 14 '15 06:01 xifan-xf