Android动画的几种实现方式总结

1、AnimatorSet

AnimatorSet set = new AnimatorSet();
set.playTogether(
        ObjectAnimator.ofFloat( imageViewOne, "scaleX" , 1, 1.3f, 1 ),
        ObjectAnimator. ofFloat(imageViewOne, "scaleY", 1 , 1.3f, 1),
        ObjectAnimator. ofFloat(imageViewTwo, "translationX", 0 , 60, 30),
        ObjectAnimator. ofFloat(imageViewTwo, "translationY", 0 , 60, 30),
        ObjectAnimator. ofFloat(imageViewThree, "alpha", 0 , 1) ,
        ObjectAnimator. ofFloat(imageViewFour, "rotation", 0 , 180)
);
//减速器
 set.setInterpolator(new AccelerateDecelerateInterpolator()) ;
//加速器
set.setInterpolator(new AccelerateInterpolator()) ;
//延迟
set.setStartDelay(1000) ;
//监听器
set.addListener( this);
set.setDuration(6000).start() ;

或者:


//改变透明度:

    
//旋转:
    
    
//缩放:
    
    
//平移:
    


//Java代码:
Animation animation=
            AnimationUtils.loadAnimation(context,相应的xml文件);
imageVie.startAnimation(animation);

2、ViewCompat

  ViewCompat.animate(view)
                    .scaleX(0.f)
                    .scaleY(0.f)
                    .rotationBy(360)
                    .translationX(60f)
                    .translationY(60f)
                    .setStartDelay(500)
                    .setDuration(1000)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {

                        }
                    });

3、AnimationDrawable



    

    

    ...

    



    

你可能感兴趣的:(Android动画的几种实现方式总结)