属性动画的基本用法

前段时间有个需求 项目里面需要做一个动画,以前虽然知道属性动画,但是没有好好用过,所以 以战代练是最好的办法咯!

(gif图片没有上传成功,下次再尝试)


开始我找各种动画效果的名字找了好久 现在我总结一下

里面最主要的就是:

ObjectAnimator animatorSetTextRegistTranslationX=ObjectAnimator.ofFloat(mRegist,"translationX",300f,-200f,100f,-50f,10f,0f).setDuration(mLongLongDurationTime);//X轴位移
ObjectAnimator animatorSetTextRegistScaleX= ObjectAnimator.ofFloat(mRegist,"scaleX",0,2.0f,0.8f,1.1f,0.95f,1.0f).setDuration(mLongLongDurationTime);//X轴缩放
ObjectAnimator animatorSetTextRegistScaleY= ObjectAnimator.ofFloat(mRegist,"scaleY",0,2.0f,0.8f,1.1f,0.95f,1.0f).setDuration(mLongLongDurationTime);//Y轴缩放

ObjectAnimator animatorSetTextRegistAlpha= ObjectAnimator.ofFloat(mRegist,"alpha",0,1.0f).setDuration(mLongLongDurationTime);//透明度变化

ObjectAnimator animatorSetTextSuccessfullyRotation=ObjectAnimator.ofFloat(mSuccessful,"rotation",-180,0).setDuration(mDurationTime);//平面旋转效果 其实就是Z轴旋转效果
ObjectAnimator objectAnimatorCionOneRotationX=ObjectAnimator.ofFloat(mImageViewCionOne,"rotationX",-200f,0f,180,0f).setDuration(mLongLongDurationTime);//X轴旋转效果
ObjectAnimator objectAnimatorCionOneRotationY=ObjectAnimator.ofFloat(mImageViewCionOne,"rotationY",169f,-60f,0f).setDuration(mLongLongDurationTime);//Y轴旋转效果
三种旋转效果组合起来  就可以类似伪3D的旋转效果了

基础的属性动画就这些 但是很明显 这个不太能满足我们的需要


接下来 就要放大招了

如果我们需要组合动画呢 怎么办 

那么 就会有动画集合AnimatorSet

用法很简单

AnimatorSet animatorSetNumberList=new AnimatorSet();//创建一个对象
animatorSetNumberList.setStartDelay(700);//设置动画延时时间
animatorSetNumberList.playSequentially(animatorSetNumberOne,animatorSetNumberTwo,animatorSetNumberThree,animatorSetNumberFour,animatorSetNumberFive);//这个就厉害了我的哥,这个是让里面的动画一次执行
animatorSetNumberFive.playTogether(objectAnimatorNumberFive,objectAnimatorNumberFiveScaleX,objectAnimatorNumberFiveScaleY,objectAnimatorNumberFourRemove);//这个就是同时播放动画
animatorSetAllOfAnimator.start();//最后 只要start就可以了 

所以大家可以根据自己的需要 合理的调整执行时机 执行时间长度 执行的顺序  

当然 还有下面的方式可以控制播放顺序

AnimatorSet animSet = new AnimatorSet();
animSet.play(anim1).with(anim2);
animSet.play(anim2).with(anim3);
animSet.play(anim4).after(anim3);
animSet.setDuration(1000);
animSet.start();
这个就看个人喜好了。

当然 每个动画还可以设置监听

animatorSetBox.addListener(new Animator.AnimatorListener() {
    @Override
    public void onAnimationStart(Animator animation) {

    }

    @Override
    public void onAnimationEnd(Animator animation) {
    findViewById(R.id.iv_shadow).setVisibility(View.VISIBLE);
    }

    @Override
    public void onAnimationCancel(Animator animation) {

    }

    @Override
    public void onAnimationRepeat(Animator animation) {

    }
});
按照上面的监听 可以根据自己的需要 自行的修改逻辑


上面是基础的属性动画,在这里还记录一个ValueAnimator

用法是下面这样的:

ValueAnimator animator = ValueAnimator.ofInt(0,100);//设置数值范围 这个可以随意设置
animator.setStartDelay(1500);//延时播放时间
animator.setDuration(2000);//播放时长
animator.setRepeatMode(ValueAnimator.RESTART);//播放模式
animator.start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {//设置动画监听
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
        int curValue = (int)animation.getAnimatedValue();//获取变化的数值
        mCoinsView.setDurationTime(curValue);//根据不同的数值 对布局做平移
    }
});
也可以:

ValueAnimator animator = ValueAnimator.ofFloat(0,100);
在监听中 curValue的数值是变化的  变化范围是开始设置的范围 这时就可以根据变化的值来做不同的操作了 如平移 缩放 转弯 旋转   当然还可以加入到数学的sin cos 等等 

怎么玩就看你自己了 





不多说 直接上代码:

private void startAnimator(){
      Animator sunshine= mBuyNow.getHighLightAnim(2080,1100,findViewById(R.id.imageview_sunshine));
//        sunshine.setStartDelay(1100);
        // 背景
        ObjectAnimator objectAnimatorBackgrand=ObjectAnimator.ofFloat(rlBgAnimation,"scaleX",0,1.2f,0.9f,1.0f).setDuration(300);

        //regist文字
        AnimatorSet animatorSetTextRegist=new AnimatorSet();
        ObjectAnimator animatorSetTextRegistTranslationX=ObjectAnimator.ofFloat(mRegist,"translationX",300f,-200f,100f,-50f,10f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator animatorSetTextRegistScaleX= ObjectAnimator.ofFloat(mRegist,"scaleX",0,2.0f,0.8f,1.1f,0.95f,1.0f).setDuration(mLongLongDurationTime);
        ObjectAnimator animatorSetTextRegistScaleY= ObjectAnimator.ofFloat(mRegist,"scaleY",0,2.0f,0.8f,1.1f,0.95f,1.0f).setDuration(mLongLongDurationTime);
        ObjectAnimator animatorSetTextRegistAlpha= ObjectAnimator.ofFloat(mRegist,"alpha",0,1.0f).setDuration(mLongLongDurationTime);
        animatorSetTextRegist.setStartDelay(100);
        animatorSetTextRegist.playTogether(animatorSetTextRegistTranslationX,animatorSetTextRegistScaleX,animatorSetTextRegistScaleY,animatorSetTextRegistAlpha);

        //successfully文字
        AnimatorSet animatorSetTextSuccessfully=new AnimatorSet();
        ObjectAnimator animatorSetTextSuccessfullyRotation=ObjectAnimator.ofFloat(mSuccessful,"rotation",-180,0).setDuration(mDurationTime);
        ObjectAnimator animatorSetTextSuccessfullyScaleX= ObjectAnimator.ofFloat(mSuccessful,"scaleX",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator animatorSetTextSuccessfullyScaleY= ObjectAnimator.ofFloat(mSuccessful,"scaleY",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator animatorSetTextSuccessfullyAlpha= ObjectAnimator.ofFloat(mSuccessful,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetTextSuccessfully.setStartDelay(100);
        animatorSetTextSuccessfully.playTogether(animatorSetTextSuccessfullyRotation,animatorSetTextSuccessfullyScaleX,animatorSetTextSuccessfullyScaleY,animatorSetTextSuccessfullyAlpha);

        //宝箱
        AnimatorSet animatorSetBox=new AnimatorSet();
        ObjectAnimator objectAnimatorBoxTranslationX=ObjectAnimator.ofFloat(ivBox,"translationX",400f,-50f,50f,0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorBoxScaleX= ObjectAnimator.ofFloat(ivBox,"scaleX",0,1.5f,0.9f,1f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorBoxScaleY= ObjectAnimator.ofFloat(ivBox,"scaleY",0,1.5f,0.9f,1f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorBoxAlpha= ObjectAnimator.ofFloat(ivBox,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetBox.setStartDelay(100);
        animatorSetBox.playTogether(objectAnimatorBoxTranslationX,objectAnimatorBoxScaleX,objectAnimatorBoxScaleY,objectAnimatorBoxAlpha);
        animatorSetBox.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                findViewById(R.id.iv_shadow).setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });

        //金币发射

        AnimatorSet animatorSetCionOne=new AnimatorSet();
        ObjectAnimator objectAnimatorCionOneRotation=ObjectAnimator.ofFloat(mImageViewCionOne,"rotation",250f,-30f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneRotationX=ObjectAnimator.ofFloat(mImageViewCionOne,"rotationX",-200f,0f,180,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneRotationY=ObjectAnimator.ofFloat(mImageViewCionOne,"rotationY",169f,-60f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneTranslationY=ObjectAnimator.ofFloat(mImageViewCionOne,"translationY",150f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneTranslationX=ObjectAnimator.ofFloat(mImageViewCionOne,"translationX",200f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneScaleX= ObjectAnimator.ofFloat(mImageViewCionOne,"scaleX",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneScaleY= ObjectAnimator.ofFloat(mImageViewCionOne,"scaleY",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionOneAlpha= ObjectAnimator.ofFloat(mImageViewCionOne,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionOne.setStartDelay(600);
        animatorSetCionOne.playTogether(objectAnimatorCionOneTranslationY,objectAnimatorCionOneTranslationX,objectAnimatorCionOneScaleX,
                objectAnimatorCionOneRotation,objectAnimatorCionOneRotationX,objectAnimatorCionOneRotationY,objectAnimatorCionOneScaleY,objectAnimatorCionOneAlpha);

        AnimatorSet animatorSetCionTwo=new AnimatorSet();
        ObjectAnimator objectAnimatorCionTwoRotation=ObjectAnimator.ofFloat(mImageViewCionTwo,"rotation",250f,-30f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoRotationX=ObjectAnimator.ofFloat(mImageViewCionTwo,"rotationX",-200f,0f,180,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoRotationY=ObjectAnimator.ofFloat(mImageViewCionTwo,"rotationY",169f,-60f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoTranslationY=ObjectAnimator.ofFloat(mImageViewCionTwo,"translationY",460f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoTranslationX=ObjectAnimator.ofFloat(mImageViewCionTwo,"translationX",-230f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoScaleX= ObjectAnimator.ofFloat(mImageViewCionTwo,"scaleX",0,1f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoScaleY= ObjectAnimator.ofFloat(mImageViewCionTwo,"scaleY",0,1f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionTwoAlpha= ObjectAnimator.ofFloat(mImageViewCionTwo,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionTwo.setStartDelay(600);
        animatorSetCionTwo.playTogether(objectAnimatorCionTwoTranslationY,objectAnimatorCionTwoTranslationX,objectAnimatorCionTwoScaleX,
                objectAnimatorCionTwoRotation,objectAnimatorCionTwoRotationX,objectAnimatorCionTwoRotationY,objectAnimatorCionTwoScaleY,objectAnimatorCionTwoAlpha);


        AnimatorSet animatorSetCionThree=new AnimatorSet();
        ObjectAnimator objectAnimatorCionThreeRotation=ObjectAnimator.ofFloat(mImageViewCionThree,"rotation",250f,-30f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeRotationX=ObjectAnimator.ofFloat(mImageViewCionThree,"rotationX",-200f,0f,180,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeRotationY=ObjectAnimator.ofFloat(mImageViewCionThree,"rotationY",169f,-60f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeTranslationY=ObjectAnimator.ofFloat(mImageViewCionThree,"translationY",430f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeTranslationX=ObjectAnimator.ofFloat(mImageViewCionThree,"translationX",-180f,0f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeScaleX= ObjectAnimator.ofFloat(mImageViewCionThree,"scaleX",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeScaleY= ObjectAnimator.ofFloat(mImageViewCionThree,"scaleY",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionThreeAlpha= ObjectAnimator.ofFloat(mImageViewCionThree,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionThree.setStartDelay(600);
        animatorSetCionThree.playTogether(objectAnimatorCionThreeTranslationY,objectAnimatorCionThreeTranslationX,objectAnimatorCionThreeScaleX,
                objectAnimatorCionThreeRotation,objectAnimatorCionThreeRotationX,objectAnimatorCionThreeRotationY,objectAnimatorCionThreeScaleY,objectAnimatorCionThreeAlpha);

        AnimatorSet animatorSetCionFour=new AnimatorSet();
        ObjectAnimator objectAnimatorCionFourRotation=ObjectAnimator.ofFloat(mImageViewCionFour,"rotation",250f,-30f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFourRotationX=ObjectAnimator.ofFloat(mImageViewCionFour,"rotationX",-200f,0f,90,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFourRotationY=ObjectAnimator.ofFloat(mImageViewCionFour,"rotationY",169f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFourTranslationY=ObjectAnimator.ofFloat(mImageViewCionFour,"translationY",-300f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFourTranslationX=ObjectAnimator.ofFloat(mImageViewCionFour,"translationX",-180f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFourScaleX= ObjectAnimator.ofFloat(mImageViewCionFour,"scaleX",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionFourScaleY= ObjectAnimator.ofFloat(mImageViewCionFour,"scaleY",0,1f).setDuration(mLongLongDurationTime);
        ObjectAnimator objectAnimatorCionFourAlpha= ObjectAnimator.ofFloat(mImageViewCionFour,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionFour.setStartDelay(800);
        animatorSetCionFour.playTogether(objectAnimatorCionFourTranslationY,objectAnimatorCionFourTranslationX,objectAnimatorCionFourScaleX,
                objectAnimatorCionFourRotation,objectAnimatorCionFourRotationX,objectAnimatorCionFourRotationY,objectAnimatorCionFourScaleY,objectAnimatorCionFourAlpha);

        AnimatorSet animatorSetCionFive=new AnimatorSet();
        ObjectAnimator objectAnimatorCionFiveRotation=ObjectAnimator.ofFloat(mImageViewCionFive,"rotation",-50f,150f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveRotationX=ObjectAnimator.ofFloat(mImageViewCionFive,"rotationX",-120f,0f,60,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveRotationY=ObjectAnimator.ofFloat(mImageViewCionFive,"rotationY",-69f,60f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveTranslationY=ObjectAnimator.ofFloat(mImageViewCionFive,"translationY",50f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveTranslationX=ObjectAnimator.ofFloat(mImageViewCionFive,"translationX",400f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveScaleX= ObjectAnimator.ofFloat(mImageViewCionFive,"scaleX",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveScaleY= ObjectAnimator.ofFloat(mImageViewCionFive,"scaleY",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionFiveAlpha= ObjectAnimator.ofFloat(mImageViewCionFive,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionFive.setStartDelay(600);
        animatorSetCionFive.playTogether(objectAnimatorCionFiveTranslationY,objectAnimatorCionFiveTranslationX,objectAnimatorCionFiveScaleX,
                objectAnimatorCionFiveRotation,objectAnimatorCionFiveRotationX,objectAnimatorCionFiveRotationY,objectAnimatorCionFiveScaleY,objectAnimatorCionFiveAlpha);

        AnimatorSet animatorSetCionSix=new AnimatorSet();
        ObjectAnimator objectAnimatorCionSixRotation=ObjectAnimator.ofFloat(mImageViewCionSix,"rotation",-50f,150f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixRotationX=ObjectAnimator.ofFloat(mImageViewCionSix,"rotationX",-120f,0f,60,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixRotationY=ObjectAnimator.ofFloat(mImageViewCionSix,"rotationY",-69f,60f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixTranslationY=ObjectAnimator.ofFloat(mImageViewCionSix,"translationY",-400f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixTranslationX=ObjectAnimator.ofFloat(mImageViewCionSix,"translationX",300f,0f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixScaleX= ObjectAnimator.ofFloat(mImageViewCionSix,"scaleX",0,1f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixScaleY= ObjectAnimator.ofFloat(mImageViewCionSix,"scaleY",0,1f).setDuration(mDurationTime3min);
        ObjectAnimator objectAnimatorCionSixAlpha= ObjectAnimator.ofFloat(mImageViewCionSix,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionSix.setStartDelay(800);
        animatorSetCionSix.playTogether(objectAnimatorCionSixTranslationY,objectAnimatorCionSixTranslationX,objectAnimatorCionSixScaleX,
                objectAnimatorCionSixRotation,objectAnimatorCionSixRotationX,objectAnimatorCionSixRotationY,objectAnimatorCionSixScaleY,objectAnimatorCionSixAlpha);

        AnimatorSet animatorSetCionSeven=new AnimatorSet();
        ObjectAnimator objectAnimatorCionSevenRotation=ObjectAnimator.ofFloat(mImageViewCionSeven,"rotation",-50f,150f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenRotationX=ObjectAnimator.ofFloat(mImageViewCionSeven,"rotationX",-120f,0f,60,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenRotationY=ObjectAnimator.ofFloat(mImageViewCionSeven,"rotationY",-69f,60f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenTranslationY=ObjectAnimator.ofFloat(mImageViewCionSeven,"translationY",400f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenTranslationX=ObjectAnimator.ofFloat(mImageViewCionSeven,"translationX",410f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenScaleX= ObjectAnimator.ofFloat(mImageViewCionSeven,"scaleX",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenScaleY= ObjectAnimator.ofFloat(mImageViewCionSeven,"scaleY",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionSevenAlpha= ObjectAnimator.ofFloat(mImageViewCionSeven,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionSeven.setStartDelay(600);
        animatorSetCionSeven.playTogether(objectAnimatorCionSevenTranslationY,objectAnimatorCionSevenTranslationX,objectAnimatorCionSevenScaleX,
                objectAnimatorCionSevenRotation,objectAnimatorCionSevenRotationX,objectAnimatorCionSevenRotationY,objectAnimatorCionSevenScaleY,objectAnimatorCionSevenAlpha);

        AnimatorSet animatorSetCionEight=new AnimatorSet();
        ObjectAnimator objectAnimatorCionEightRotation=ObjectAnimator.ofFloat(mImageViewCionEight,"rotation",-50f,150f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightRotationX=ObjectAnimator.ofFloat(mImageViewCionEight,"rotationX",-120f,0f,60,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightRotationY=ObjectAnimator.ofFloat(mImageViewCionEight,"rotationY",-69f,60f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightTranslationY=ObjectAnimator.ofFloat(mImageViewCionEight,"translationY",800f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightTranslationX=ObjectAnimator.ofFloat(mImageViewCionEight,"translationX",300f,0f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightScaleX= ObjectAnimator.ofFloat(mImageViewCionEight,"scaleX",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightScaleY= ObjectAnimator.ofFloat(mImageViewCionEight,"scaleY",0,1f).setDuration(mDurationTime2min);
        ObjectAnimator objectAnimatorCionEightAlpha= ObjectAnimator.ofFloat(mImageViewCionEight,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetCionEight.setStartDelay(600);
        animatorSetCionEight.playTogether(objectAnimatorCionEightTranslationY,objectAnimatorCionEightTranslationX,objectAnimatorCionEightScaleX,
                objectAnimatorCionEightRotation,objectAnimatorCionEightRotationX,objectAnimatorCionEightRotationY,objectAnimatorCionEightScaleY,objectAnimatorCionEightAlpha);

        //所有金币汇总
        AnimatorSet animatorSetAllCions=new AnimatorSet();
        animatorSetAllCions.playTogether(animatorSetCionOne,animatorSetCionTwo,animatorSetCionThree,
                animatorSetCionFour,animatorSetCionFive,animatorSetCionSix,animatorSetCionSeven,animatorSetCionEight);

        //coin文字
        AnimatorSet animatorSetText=new AnimatorSet();
        ObjectAnimator objectAnimatorTextScaleX= ObjectAnimator.ofFloat(relativeLayout,"scaleX",0,1.2f,0.95f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorTextScaleY= ObjectAnimator.ofFloat(relativeLayout,"scaleY",0,1.2f,0.95f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorTextAlpha= ObjectAnimator.ofFloat(relativeLayout,"alpha",0,1.0f).setDuration(mDurationTime);
        animatorSetText.setStartDelay(200);
        animatorSetText.playTogether(objectAnimatorTextScaleX,objectAnimatorTextAlpha,objectAnimatorTextScaleY);

        //按钮
        AnimatorSet animatorSetButton=new AnimatorSet();
        ObjectAnimator objectAnimatorButtonScaleX= ObjectAnimator.ofFloat(mBuyNow,"scaleX",0,1.3f,0.9f,1.0f).setDuration(mLongDurationTime);
        ObjectAnimator objectAnimatorButtonScaleY= ObjectAnimator.ofFloat(mBuyNow,"scaleY",0,1.3f,0.9f,1.0f).setDuration(mLongDurationTime);
        ObjectAnimator objectAnimatorButtonAlpha= ObjectAnimator.ofFloat(mBuyNow,"alpha",0,1.0f).setDuration(mLongDurationTime);
        animatorSetButton.setStartDelay(300);
        animatorSetButton.playTogether(objectAnimatorButtonScaleX,objectAnimatorButtonScaleY,objectAnimatorButtonAlpha);


        //数字
        float  parameter= lastnumber/5f;
        AnimatorSet animatorSetNumberOne=new AnimatorSet();
        int number=Math.round(parameter*1);
        imageViewOne.setText(number+"");
        ObjectAnimator objectAnimatorNumberOne= ObjectAnimator.ofFloat(imageViewOne,"alpha",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberOneScaleX= ObjectAnimator.ofFloat(imageViewOne,"scaleX",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberOneScaleY= ObjectAnimator.ofFloat(imageViewOne,"scaleY",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        animatorSetNumberOne.playTogether(objectAnimatorNumberOne,objectAnimatorNumberOneScaleX,objectAnimatorNumberOneScaleY);

        AnimatorSet animatorSetNumberTwo=new AnimatorSet();
        int number2=Math.round(parameter*2);
        imageViewTwo.setText(number2+"");
        ObjectAnimator objectAnimatorNumberTwo= ObjectAnimator.ofFloat(imageViewTwo,"alpha",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberTwoScaleX= ObjectAnimator.ofFloat(imageViewTwo,"scaleX",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberTwoScaleY= ObjectAnimator.ofFloat(imageViewTwo,"scaleY",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberOneRemove= ObjectAnimator.ofFloat(imageViewOne,"alpha",1.0f,0).setDuration(mDurationTime);
        animatorSetNumberTwo.playTogether(objectAnimatorNumberTwo,objectAnimatorNumberTwoScaleX,objectAnimatorNumberTwoScaleY,objectAnimatorNumberOneRemove);

        AnimatorSet animatorSetNumberThree=new AnimatorSet();
        int number3=Math.round(parameter*3);
        imageViewThree.setText(number3+"");
        ObjectAnimator objectAnimatorNumberThree= ObjectAnimator.ofFloat(imageViewThree,"alpha",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberThreeScaleX= ObjectAnimator.ofFloat(imageViewThree,"scaleX",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberThreeScaleY= ObjectAnimator.ofFloat(imageViewThree,"scaleY",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberTwoRemove= ObjectAnimator.ofFloat(imageViewTwo,"alpha",1.0f,0).setDuration(mDurationTime);
        animatorSetNumberThree.playTogether(objectAnimatorNumberThree,objectAnimatorNumberThreeScaleX,objectAnimatorNumberThreeScaleY,objectAnimatorNumberTwoRemove);

        AnimatorSet animatorSetNumberFour=new AnimatorSet();
        int number4=Math.round(parameter*4);
        imageViewFour.setText(number4+"");
        ObjectAnimator objectAnimatorNumberFour= ObjectAnimator.ofFloat(imageViewFour,"alpha",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberFourScaleX= ObjectAnimator.ofFloat(imageViewFour,"scaleX",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberFourScaleY= ObjectAnimator.ofFloat(imageViewFour,"scaleY",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberThreeRemove= ObjectAnimator.ofFloat(imageViewThree,"alpha",1.0f,0).setDuration(mDurationTime);
        animatorSetNumberFour.playTogether(objectAnimatorNumberFour,objectAnimatorNumberFourScaleX,objectAnimatorNumberFourScaleY,objectAnimatorNumberThreeRemove);

        AnimatorSet animatorSetNumberFive=new AnimatorSet();
        int number5=Math.round(parameter*5);
        imageViewFive.setText(number5+"");
        ObjectAnimator objectAnimatorNumberFive= ObjectAnimator.ofFloat(imageViewFive,"alpha",0,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberFiveScaleX= ObjectAnimator.ofFloat(imageViewFive,"scaleX",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberFiveScaleY= ObjectAnimator.ofFloat(imageViewFive,"scaleY",1.0f,1.1f,0.9f,1.0f).setDuration(mDurationTime);
        ObjectAnimator objectAnimatorNumberFourRemove= ObjectAnimator.ofFloat(imageViewFour,"alpha",1.0f,0).setDuration(mDurationTime);
        animatorSetNumberFive.playTogether(objectAnimatorNumberFive,objectAnimatorNumberFiveScaleX,objectAnimatorNumberFiveScaleY,objectAnimatorNumberFourRemove);

        //数字变化集合,依次播放
        AnimatorSet animatorSetNumberList=new AnimatorSet();
        animatorSetNumberList.setStartDelay(700);
        animatorSetNumberList.playSequentially(animatorSetNumberOne,animatorSetNumberTwo,animatorSetNumberThree,animatorSetNumberFour,animatorSetNumberFive);

        AnimatorSet animatorSetAllOfAnimator=new AnimatorSet();
        animatorSetAllOfAnimator.playTogether(animatorSetButton,
                animatorSetAllCions,objectAnimatorBackgrand,animatorSetTextRegist,animatorSetTextSuccessfully,
                animatorSetBox,animatorSetText,animatorSetNumberList,sunshine);
        mAnimator = animatorSetAllOfAnimator;
        animatorSetAllOfAnimator.start();
    }


代码虽然有点多 但是 有用的真的没几行(我这样说自己的代码真的好么), 


好了 属性动画先写到这里。

书山有路勤为径,学海无涯苦作舟。

大家共勉,一起进步!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值