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();
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。