Open zhonglushu opened 8 years ago
this happens for me too! when I fling quickly to the top, my header image suddenly appears at the bottom where it shouldn't be appearing
here's my scroll callback, I thought maybe I'm doing something wrong here:
new ObservableScrollViewCallbacks(){
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging){
//if (!layout_ready) return;
float coeff = getFloat(scrollY / (float) title_container.getTop(), 0, 1);
pinned_background.setAlpha(coeff);
bottom_shadow.setAlpha(pinned_background.getAlpha());
header_image.setTranslationY(-scrollY);
title.setAlpha(getFloat(1f - coeff, 0.9f, 1f));
title_container.setTranslationY(
getFloat(-scrollY, -(title_container.getTop()) + U.dp2px(10), 0));
title_container.setTranslationX(-coeff * U.dp2px(25));
pinned_background.setTranslationY(
getFloat(-scrollY, -header_image.getHeight() + toolbar.getHeight(), 0));
bottom_shadow.setTranslationY(pinned_background.getTranslationY());
fab.setTranslationY(-scrollY);
}
@Override public void onDownMotionEvent(){
}
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState){
}
}
I logged the scrollY parameter and yes it returns negative numbers sometimes when i fling fast!
E: onScrollChanged() called with: scrollY = [5516], firstScroll = [false], dragging = [true]
E: onScrollChanged() called with: scrollY = [5092], firstScroll = [false], dragging = [true]
E: onScrollChanged() called with: scrollY = [5070], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [4856], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [4578], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [4192], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [1939], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [-87], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [-1011], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [-1308], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [534], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [249], firstScroll = [false], dragging = [false]
E: onScrollChanged() called with: scrollY = [0], firstScroll = [false], dragging = [false]
I'm facing the same problem here!! Any updates ??
I switched to RecyclerView
's own onScrollListener
and everything worked smoothly, you should too.
After I scroll down bottom, I want to scroll up top, and I scroll up very quickly, then I found scroller will scroll up top but not show toolbar, and it will scroll back from top to bottom.