属性动画ObjectAnimator 滑动恢复原位

mMatchRatingRelativeLayout.setTranslationY(0);

 

 

ObjectAnimator firstAllViewAnimation = ObjectAnimator.ofFloat(mMatchRatingFirstAllView, "alpha", 1.0f, 0.0f);
ObjectAnimator matchRatingAvatarAnimation = ObjectAnimator.ofFloat(mMatchRatingUserAvatar, "alpha", 1.0f, 0.0f);
AnimatorSet firstAnimatorSet = new AnimatorSet();
firstAnimatorSet.play(firstAllViewAnimation).with(matchRatingAvatarAnimation);
firstAnimatorSet.setDuration(100);
firstAnimatorSet.start();
firstAnimatorSet.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
        super.onAnimationEnd(animation);
        if (mMatchRatingRelativeLayout == null) {return;}
        mMatchRatingUserAvatar.setImageDrawable(ResourceUtil.getDrawable(R.drawable.icon_chang_avatar_small_pic));
        mMatchRatingFirstAllView.setVisibility(View.GONE);
        mMatchRatingAnimationAllView.setAlpha(0);
        mMatchRatingAnimationAllView.setVisibility(View.VISIBLE);
        ObjectAnimator avatarScaleXAnimator = ObjectAnimator.ofFloat(mMatchRatingUserAvatar, "scaleX", 0.5f, 1.0f);
        ObjectAnimator avatarScaleYAnimator = ObjectAnimator.ofFloat(mMatchRatingUserAvatar, "scaleY", 0.5f, 1.0f);
        ObjectAnimator avatarAlphaAnimator = ObjectAnimator.ofFloat(mMatchRatingUserAvatar, "alpha", 0.0f, 1.0f);
        ObjectAnimator animationAllViewAlphaAnimator = ObjectAnimator.ofFloat(mMatchRatingAnimationAllView, "alpha", 0.0f, 1.0f);
        ObjectAnimator matchRatingEmojiScaleXAnimator = ObjectAnimator.ofFloat(mMatchRatingEmoji, "scaleX", 1.0f, 1.3f);
        ObjectAnimator matchRatingEmojiScaleYAnimator = ObjectAnimator.ofFloat(mMatchRatingEmoji, "scaleY", 1.0f, 1.3f);
        AnimatorSet secondAnimatorSet = new AnimatorSet();
        secondAnimatorSet.play(avatarScaleXAnimator).with(avatarScaleYAnimator).with(avatarAlphaAnimator).with(animationAllViewAlphaAnimator)
                .with(animationAllViewAlphaAnimator).with(matchRatingEmojiScaleXAnimator).with(matchRatingEmojiScaleYAnimator);
        secondAnimatorSet.setDuration(200);
        secondAnimatorSet.start();
        secondAnimatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                if (mMatchRatingRelativeLayout == null) {return;}
                ObjectAnimator matchRatingEmojiScaleXAnimator = ObjectAnimator.ofFloat(mMatchRatingEmoji, "scaleX", 1.3f, 1.0f);
                ObjectAnimator matchRatingEmojiScaleYAnimator = ObjectAnimator.ofFloat(mMatchRatingEmoji, "scaleY", 1.3f, 1.0f);
                AnimatorSet thirdAnimatorSet = new AnimatorSet();
                thirdAnimatorSet.play(matchRatingEmojiScaleXAnimator).with(matchRatingEmojiScaleYAnimator);
                thirdAnimatorSet.setDuration(100);
                thirdAnimatorSet.start();
                ObjectAnimator matchRatingALLAnimator = ObjectAnimator.ofFloat(mMatchRatingRelativeLayout, "translationY", mMatchRatingRelativeLayout.getY(), mMatchRatingRelativeLayout.getY() + WindowUtil.getScreenHeight());
                matchRatingALLAnimator.setDuration(200);
                matchRatingALLAnimator.setStartDelay(500);
                matchRatingALLAnimator.start();
                matchRatingALLAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        if (mMatchRatingRelativeLayout == null) {return;}
                        mMatchRatingRelativeLayout.setVisibility(View.GONE);
                        mMatchRatingAnimationAllView.setVisibility(View.GONE);
                        mMatchRatingRelativeLayout.setTranslationY(0);
                    }
                });
            }
        });
    }

你可能感兴趣的:(属性动画ObjectAnimator 滑动恢复原位)