Animation of MenuItem in ActionBar

The task is to animate menu icon in the ActionBar. In my case this is “reload” image:

Screen Shot 2015-05-01 at 22.54.40
Icon to be animated

First of all we need to edit menu item in the menu_reload.xml:

If we are using AppCompat library, we should add  compat:actionViewClass="android.widget.ImageView" parameter, or android:actionViewClass  otherwise.

Next we need to use some animation for the MenuItem (rotation in my case). To do this I’ve created rotation.xml  file:

Than we can use this animation in that way:

In the  onCreateOptionsMenu()  method we can get our item’s view by using menu.findItem(;  method. Than we need to specify it’s image view, use rotation animation and set click listener. Well done:

Leave a Reply