2.平移java
ObjectAnimator anim1 = ObjectAnimator.ofFloat(balls.get(0), "y", 0f, getHeight() - balls.get(0).getHeight()).setDuration(500);
3.複製動畫動畫
ObjectAnimator anim2 = anim1.clone(); anim2.setTarget(balls.get(1));
4.添加監聽器this
anim1.addUpdateListener(this);
5.動畫集code
//動畫一 ObjectAnimator animDown = ObjectAnimator.ofFloat(ball2, "y", 0f, getHeight() - ball2.getHeight()).setDuration(500); //設置加速器 animDown.setInterpolator(new AccelerateInterpolator()); //動畫二 ObjectAnimator animUp = ObjectAnimator.ofFloat(ball2, "y", getHeight() - ball2.getHeight(), 0f).setDuration(500); //設置減速器 animUp.setInterpolator(new DecelerateInterpolator()); //動畫集 AnimatorSet s1 = new AnimatorSet(); //設置動畫播放順序 s1.playSequentially(animDown, animUp);
六、複製動畫集get
AnimatorSet s2 = (AnimatorSet) s1.clone(); s2.setTarget(balls.get(3));
七、播放動畫animation
animation = new AnimatorSet(); animation.playTogether(anim1, anim2, s1); animation.playSequentially(s1, s2); animation.start();