代码较少,废话就不多说了,直接上代码
private ImageView musicPlate;
/**开始旋转**/
private void startAnimation(){
animation = new RotateAnimation(0, 360,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f);
/**设置旋转一圈所需时间**/
animation.setDuration(10000);
/**设置旋转次数,近乎无限次**/
animation.setRepeatCount(Integer.MAX_VALUE);
/**设置旋转无停顿**/
animation.setInterpolator(new LinearInterpolator());
animation.setFillAfter(true);
musicPlate.startAnimation(animation);
}
/**结束旋转**/
private void stopAnimation(){
if(animation != null){
animation.cancel();
animation = null;
}
}