Search code examples
androidandroid-actionbarandroid-custom-view

Refresh animation in actionbar customview imagebutton


I created an application from a demo. The application is enabled with actionbar. It contain customview in top and actionview items in bottom. In the top custom view an imagebutton is located. I want rounding circle animation (refresh animation) when the imagebutton is clicked. Is any solution for this ?


Solution

  • Finally i got a solution

    imageButton = (ImageButton) mCustomView.findViewById(R.id.imageButton);
    

    animation starting

    RotateAnimation rotate = new RotateAnimation(0,360,
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(1000);
    rotate.setRepeatCount(Animation.INFINITE);
    rotate.setRepeatMode(Animation.INFINITE);
    rotate.setInterpolator(new LinearInterpolator());
    imageButton.startAnimation(rotate);
    

    animation stopping

    imageButton.clearAnimation();