ConsecutiveScroller icon indicating copy to clipboard operation
ConsecutiveScroller copied to clipboard

什么情况下ConsecutiveScrollerLayout的滑动监听会出现无法获取scrollY的滑动量的情况求

Open 18640243061 opened this issue 2 years ago • 5 comments

18640243061 avatar Mar 09 '22 10:03 18640243061

当ConsecutiveScrollerLayout下包含的recycler view中含有图片时会引起ConsecutiveScrollerLayout的滑动监听无法获取scrollY的滑动量希望您能看一下这个情况

18640243061 avatar Mar 09 '22 11:03 18640243061

因为如果RecyclerView的item高度不是统一并且固定的,那么RecyclerView也是没法获取正确的scrollY的。所以这种情况下,也会导致ConsecutiveScrollerLayout获取的scrollY不正确

donkingliang avatar Mar 10 '22 02:03 donkingliang

@Nullable
@Override
protected Parcelable onSaveInstanceState() {
    MyInstanceState myInstanceState = new MyInstanceState(super.onSaveInstanceState());
    myInstanceState.scrollY = getScrollY();
    return myInstanceState;
}

@Override
protected void onRestoreInstanceState(Parcelable state) {
    super.onRestoreInstanceState(state);
    if (state instanceof MyInstanceState) {
        scrollTo(0, ((MyInstanceState) state).scrollY);
    }
}

mosentest avatar Nov 07 '23 06:11 mosentest

@Nullable
@Override
protected Parcelable onSaveInstanceState() {
    MyInstanceState myInstanceState = new MyInstanceState(super.onSaveInstanceState());
    myInstanceState.scrollY = getScrollY();
    return myInstanceState;
}

@Override
protected void onRestoreInstanceState(Parcelable state) {
    super.onRestoreInstanceState(state);
    if (state instanceof MyInstanceState) {
        scrollBy(0, ((MyInstanceState) state).scrollY);
    }
}

mosentest avatar Nov 07 '23 07:11 mosentest

没效果

mosentest avatar Nov 07 '23 07:11 mosentest