自定義dialog消失動畫,對話框添加購物車飛入動畫

動畫縮放飛入關鍵代碼:
   ObjectAnimator animatorScaleX = ObjectAnimator.ofFloat(mView, "scaleX", 1.0f, 0.1f);
    ObjectAnimator animatorScaleY = ObjectAnimator.ofFloat(mView, "scaleY", 1.0f, 0.1f);

    ObjectAnimator animatorX = ObjectAnimator.ofFloat(mView, "translationY", 0, UiUtils.getScreenHeight() / 2 - (int) (UiUtils.dp2px(25) + 0.5));
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(mView, "translationX", 0, -(UiUtils.getScreenWidth() / 2 - (int) (UiUtils.dp2px(20) + 0.5)));
    ObjectAnimator animatorRotation = ObjectAnimator.ofFloat(mView, "rotation", 0, 720);
    AnimatorSet set = new AnimatorSet();

    animatorScaleX.setInterpolator(new LinearInterpolator());
    animatorScaleY.setInterpolator(new LinearInterpolator());

    set.play(animatorX).with(animatorY).with(animatorRotation).after(animatorScaleX).after(animatorScaleY);
    //    set.playTogether(animatorX, animatorY, animatorRotation, animatorScaleX, animatorScaleY);
    set.setDuration(250);
    set.start();
    set.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mView != null)
                mainLayout.removeView(mView);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

效果展示圖:

 

 

 

源碼鏈接地址:https://github.com/pingcc/AnimalSetApplication

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章