Android 补间动画

1.xml写法

alpha_anim.xml



rotate_anim.xml



scale_anim.xml



translate_anim.xml


set_anim.xml



    
    

使用

 public void onAlpha(View view) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha_anim);
        animation.setFillBefore(true);
        mImageView.startAnimation(animation);
    }

2.代码实现

alpha_anim

      AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
       alpha.setDuration(1000);
       alpha.setFillBefore(true);
       alpha.setInterpolator(new LinearInterpolator());
       mImageView.setAnimation(alpha);
       alpha.start();

rotate_anim

 RotateAnimation rotateAnimation=new RotateAnimation(0f,360f,50f,50f);

scale_anim

 ScaleAnimation scaleAnimation=new ScaleAnimation(0,50,0,50);

translate_anim

TranslateAnimation translate=new TranslateAnimation(0f,100f,0,100f);

set_anim

 AnimationSet animationSet=new AnimationSet(true);
 animationSet.addAnimation(translate);
 animationSet.addAnimation(rotateAnimation);
 animationSet.addAnimation(scaleAnimation);

你可能感兴趣的:(Android 补间动画)