属性动画

来源:互联网 发布:八爪鱼采集淘宝评论 编辑:程序博客网 时间:2024/06/05 14:21
img1.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {//                ObjectAnimator//动画的执行类//                        .ofFloat(view, "rotationY", 0.0F, 360.0F)//                        .setDuration(5000)//动画持续时间//                        .start();                //多个动画一起执行//                ObjectAnimator anim1 = ObjectAnimator.ofFloat(view, "scaleX",//                        1.0f, 2f);//                ObjectAnimator anim2 = ObjectAnimator.ofFloat(view, "scaleY",//                        1.0f, 2f);//                ObjectAnimator anim3 = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);//                AnimatorSet animSet = new AnimatorSet();//                animSet.setDuration(2000);//                //  animSet.setInterpolator(new LinearInterpolator());//                //三个动画同时执行//                animSet.playTogether(anim1, anim2, anim3);//                animSet.start();                //ValueAnimation//                ValueAnimator anim = ValueAnimator.ofFloat(0f, 100f);//                anim.setRepeatMode(ValueAnimator.REVERSE);//                anim.setRepeatCount(2);//                anim.setDuration(3000);//                anim.setTarget(view);//                anim.start();                //淡入淡出                anim1 = ObjectAnimator                        .ofFloat(view, "alpha", 1f, 0f, 1f)                        .setDuration(5000);                //以Y轴旋转                anim2 = ObjectAnimator                        .ofFloat(view, "rotationY", 0.0F, 360.0F)                        .setDuration(5000);                //大小调整                anim3 = ObjectAnimator                        .ofFloat(view, "scaleY", 1.0f, 2f)                        .setDuration(5000);                anim4 = ObjectAnimator                        .ofFloat(view, "scaleX", 1.0f, 2f)                        .setDuration(5000);                anim5 = ObjectAnimator                        .ofFloat(view, "rotationX", 360.0F, 0.0F)                        .setDuration(5000);//                播放anim1;//                同时播放anim2,anim3,anim4;//                播放anim5。                AnimatorSet bouncer = new AnimatorSet();                bouncer.play(anim1).before(anim2);                bouncer.play(anim2).with(anim3);                bouncer.play(anim2).with(anim4);                bouncer.play(anim5);                bouncer.start();            }        });    }

0 0
原创粉丝点击