Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation Listener for Custom Animation

I have set Custom Animation for the fragment transaction using fragmentTansaction.setCustomAnimation(in,out). I want to know the start and end of the animation and trigger some respective action . How can I do that? Is it possible to set some listner?

like image 351
Pravy Avatar asked Aug 17 '12 07:08

Pravy


1 Answers

You can use animation in onStart() for getDecorView()

   @Override
    public void onStart() {
        super.onStart();

        if (getDialog().getWindow().getDecorView()) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(getDialog().getWindow().getDecorView(),
                    PropertyValuesHolder.ofFloat(View.Y, 0, 1000));
            objectAnimator.setDuration(1000);
            objectAnimator.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {

                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            objectAnimator.start();
        }

    }
like image 98
Rasoul Miri Avatar answered Nov 02 '22 20:11

Rasoul Miri