android animation(一)

 

  205937_IDBs_1474965.jpg

 

220455_sh63_1474965.png

2.平移

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.添加监听器

 anim1.addUpdateListener(this);

5.动画集

              //动画一
                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);

6、复制动画集

 AnimatorSet s2 = (AnimatorSet) s1.clone();
 s2.setTarget(balls.get(3));

7、播放动画

animation = new AnimatorSet();
animation.playTogether(anim1, anim2, s1);
animation.playSequentially(s1, s2);
animation.start();

转载于:https://my.oschina.net/u/1474965/blog/289541

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值