今天我们来写一个简单的等待动画,使用了专门实现rotateAnimation
代码如下:
RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); LinearInterpolator lin = new LinearInterpolator(); rotate.setInterpolator(lin); rotate.setDuration(20000);//设置动画持续周期 rotate.setRepeatCount(-1);//设置重复次数 rotate.setFillAfter(true);//动画执行完后是否停留在执行完的状态 rotate.setStartOffset(10);//执行前的等待时间
ImageView ssp=(ImageView)findViewById(R.id.image_view);
ssp.setAnimation(rotates);
ssp.setAnimation(rotates);
只需要指定好需要旋转的控件即可——是不是十分简单呢?