Code example for RotateAnimation

Methods: setDuration, setInterpolator, setRepeatCount

0
    public static void startRotating(final View view) {
        // Why this layout listener craziness? Because the view's dimensions are only known 
        // after layout is finished. requestLayout() makes sure that the listener is called. 
        view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            public void onGlobalLayout() { 
                RotateAnimation anim = new RotateAnimation(0f, 350f, view.getWidth() / 2.0f, view.getHeight() / 2.0f);
                anim.setInterpolator(new LinearInterpolator());
                anim.setRepeatCount(Animation.INFINITE);
                anim.setDuration(1000);
                view.startAnimation(anim);
                view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } 
        }); 
        view.requestLayout();
    } 
     
    public static void stopRotating(View view) {
        view.clearAnimation();
    } 
     
}