1.位移动化
TranslateAnimation animation =new TranslateAnimation(Animation.RELATIVE_TO_SELF,0f, Animation.RELATIVE_TO_SELF,1f,Animation.RELATIVE_TO_SELF,0f, Animation.RELATIVE_TO_SELF,1f);
animation.setDuration(2000);
animation.setInterpolator(this, android.R.anim.linear_interpolator);
img.startAnimation(animation);
animation.start();
2.旋转动画
RotateAnimation animation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);
animation.setDuration(5000);
animation.setInterpolator(this, android.R.anim.accelerate_interpolator);
img.startAnimation(animation);
animation.start();
3.缩放动画
ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0.6f, 1.2f, 1.0f, 0.6f, 1.2f, 1.0f);
animator.setDuration(6000L);//设置缩放时间
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float scale = (Float) animation.getAnimatedValue();
img.setScaleX(scale);
img.setScaleY(scale);
}
});
animator.setInterpolator(new LinearInterpolator());
animator.start();
4.透明动画
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setDuration(2000);
animation.setRepeatCount(-1);
img.startAnimation(animation);
animation.start();