Open duzechao opened 8 years ago
im not sure where to catch that offsets. but u can looking to i think u can try to catch with the integers on the scroll view controller.
mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (mHeader != null) {
mTotalYScrolled += dy;
if (isParallaxHeader)
translateHeader(mTotalYScrolled);
}
enableShoworHideToolbarAndFloatingButton(recyclerView);
}
};
private void translateHeader(float of) {
float ofCalculated = of * SCROLL_MULTIPLIER;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
//Logs.d("ofCalculated " + ofCalculated+" "+mHeader.getHeight());
mHeader.setTranslationY(ofCalculated);
} else {
TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated);
anim.setFillAfter(true);
anim.setDuration(0);
mHeader.startAnimation(anim);
}
mHeader.setClipY(Math.round(ofCalculated));
if (mParallaxScroll != null) {
float left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * SCROLL_MULTIPLIER)));
mParallaxScroll.onParallaxScroll(left, of, mHeader);
}
}
public static class CustomRelativeWrapper extends RelativeLayout {
private int mOffset;
public CustomRelativeWrapper(Context context) {
super(context);
}
@Override
protected void dispatchDraw(Canvas canvas) {
if (isParallaxHeader)
canvas.clipRect(new Rect(getLeft(), getTop(), getRight(), getBottom() + mOffset));
super.dispatchDraw(canvas);
}
public void setClipY(int offset) {
mOffset = offset;
invalidate();
}
}
can u make a pull request if u can find and solve the issue?
277, #262, #209, #313