Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

view.animate().translationY() fill empty space

Im animating my header view on scroll via the view animation classes as following:

view.animate()
.translationY(-view.getBottom())
.alpha(0)
.setDuration(HEADER_HIDE_ANIM_DURATION)
.setInterpolator(new DecelerateInterpolator());

Problem is that the view below the view im translating is not filling up translated views empty space:

enter image description here

enter image description here

My layout looks somethin like this:

<LinnearLayout>
   <include layout"toolbar" /> //included layout which is the view translated
   <FrameLayout  /> //fragment container
</LinnearLayout>

How do i solve this issue?

like image 633
Richard Avatar asked Feb 27 '26 15:02

Richard


1 Answers

Do you try to fade away your toolbar? Try to manipulate your FrameLayout manually. Something like this:

        ObjectAnimator animator = ValueAnimator.ofFloat(0, -view.getBottom());

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                toolbar.setTranslationY(-animation.getAnimatedValue)
                mFrameLayout.layout(mFrameLayout.getLeft(), animation.getFraction() * mToolbar.getHeight(), mFrameLayout.getRight(), mFrameLayout.getBottom());
            }
        });
        toolbar.startAnimation(animator);
like image 83
Mann Avatar answered Mar 02 '26 06:03

Mann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!