ConsecutiveScroller
ConsecutiveScroller copied to clipboard
什么情况下ConsecutiveScrollerLayout的滑动监听会出现无法获取scrollY的滑动量的情况求
当ConsecutiveScrollerLayout下包含的recycler view中含有图片时会引起ConsecutiveScrollerLayout的滑动监听无法获取scrollY的滑动量希望您能看一下这个情况
因为如果RecyclerView的item高度不是统一并且固定的,那么RecyclerView也是没法获取正确的scrollY的。所以这种情况下,也会导致ConsecutiveScrollerLayout获取的scrollY不正确
@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);
}
}
@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);
}
}
没效果