kanytu / android-parallax-recyclerview

An adapter which could be used to achieve a parallax effect on RecyclerView.
Apache License 2.0
1.61k stars 284 forks source link

overlay a header to a description element #58

Open SergeyKarleev opened 6 years ago

SergeyKarleev commented 6 years ago

https://github.com/kanytu/android-parallax-recyclerview/blob/cad6b8d619a3d2d87efa35e7a8f456f55b120dc5/library/src/main/java/com/poliveira/parallaxrecyclerview/ParallaxRecyclerAdapter.java#L99

Hello, guys I found such a bug:

  1. Make the description under the header very large
  2. Scroll so that header disappears

header disappears, and then abruptly appears and the description is superimposed on it (see image) the mRecyclerView.computeVerticalScrollOffset() on 99 line produces a value much larger than mHeader.getHeight()

if you write such a piece of code, it will work out correctly

super.onScrolled(recyclerView, dx, dy);
if (mHeader != null) {
  float verticalScrollOffset = MathUtils.min(mRecyclerView.computeVerticalScrollOffset(), 
                                                                    mHeader.getHeight());
  translateHeader(mRecyclerView.getLayoutManager().getChildAt(0) == mHeader ?
                            verticalScrollOffset : mHeader.getHeight());
}

image