Android 不停旋转图片

来源:互联网 发布:淘宝店铺交易平台 编辑:程序博客网 时间:2024/06/10 05:58

代码较少,废话就不多说了,直接上代码

    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;        }    }
0 0