我想在动画之前和之后执行一些操作。 这是我的代码: -
AnimatorSet set1 = new AnimatorSet();
set1.playTogether(
ObjectAnimator.ofFloat(ball1, "translationX", x1, xn),
ObjectAnimator.ofFloat(ball1, "translationY", y1, yn),
ObjectAnimator.ofFloat(ball2, "translationX", xn, x1),
ObjectAnimator.ofFloat(ball2, "translationY", yn, y1)
);
set1.setDuration(1000).start();
是否有任何动画设定方法可以做到这一点。??
答案 0 :(得分:1)
您可以使用 setAnimationListener :
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {
// TODO Auto-generated method stub
//code when starting animation
}
@Override
public void onAnimationRepeat(Animator arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator arg0) {
// TODO Auto-generated method stub
//code on animation end
}
@Override
public void onAnimationCancel(Animator arg0) {
// TODO Auto-generated method stub
}
});