henrytao-me / smooth-app-bar-layout

Smooth version of Google Support Design AppBarLayout
Apache License 2.0
1.77k stars 240 forks source link

ViewPager Tablayout title bar quickly sliding to the top or bottom #207

Closed changeYe closed 7 years ago

changeYe commented 7 years ago

SmoothViewPagerParallaxExitUntilCollapsedActivity: If I put CollapsingToolbarLayout height up to 500 dp, upward slide layout to the middle position, switch the TAB, if the child fragments of data is not much, TAB to slide down quickly.Sometimes, slide the TAB, the TAB will slide to the top quickly

henrytao-me commented 7 years ago

Hi @yuantongqin,

It's a known issue. I haven't had idea to fix it yet. I am sorry.

changeYe commented 7 years ago
  static  int lastOffset = 0;
  public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
    boolean isSelected = target == scroll;
    if (scroll instanceof NestedScrollView) {
      NestedScrollView nestedScrollView = (NestedScrollView) scroll;
      nestedScrollView.scrollTo(0, verticalOffset);
    } else if (scroll instanceof RecyclerView) {
      RecyclerView recyclerView = (RecyclerView) scroll;
      recyclerView.scrollBy(0, verticalOffset - lastOffset);

    }
    lastOffset = verticalOffset;
    return true;
  }

I made some changes slightly, this way the effect is better than before, there may be a mistake

henrytao-me commented 7 years ago

Hmmmmmm. Storing lastOffset as static may not be an effective way to do, imo. Would you mind to send PR? I will run the code based on your PR.

changeYe commented 7 years ago

Thank you for your help, I look at the code yourself 🙂

henrytao-me commented 7 years ago

Hi @yuantongqin, you can try original Support Library 26.0.0. The flinging issue of AppBarLayout is fixed.