android animation(一)

 

 

 

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();
相关文章
相关标签/搜索