抖音关注动画

抖音关注动画

public void propertyValuesHolder(final View view){
    final PropertyValuesHolder pvhx = PropertyValuesHolder.ofFloat("alpha",1f,0f);
    PropertyValuesHolder pvhy = PropertyValuesHolder.ofFloat("scaleX",1f,0f);
    PropertyValuesHolder pvhz = PropertyValuesHolder.ofFloat("scaleY",1f,0f);

    final ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(view,pvhx,pvhy,pvhz);

    PropertyValuesHolder pvhx1 = PropertyValuesHolder.ofFloat("alpha",0f,1f);
    PropertyValuesHolder pvhy1 = PropertyValuesHolder.ofFloat("scaleX",0f,1f);
    PropertyValuesHolder pvhz1 = PropertyValuesHolder.ofFloat("scaleY",0f,1f);
    final ObjectAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(view,pvhx1,pvhy1,pvhz1);

    animator1.setDuration(1000).start();
    animator1.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            ((ImageView)view).setImageResource(R.mipmap.png_good);
            animator2.setDuration(1000).start();

        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

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

        }

        @Override
        public void onAnimationEnd(Animator animation) {

            ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(linearLayout,pvhx);
            objectAnimator.setDuration(1000).start();

        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

}

view为imageview,原始src为+,
R.mipmap.png_good 关注成功png √
linearLayout 为背景 直接传入imageview即可运行

你可能感兴趣的:(移动开发,Android开发)