Reputation: 2205
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?
Upvotes: 7
Views: 1034
Reputation: 12222
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();
}
}
Upvotes: 1