Search code examples
androidanimationandroid-actionbarandroid-toolbarmenuitem

How to change the contents of actionbar using animations in Android?


I want to change the contents of the actionbar when I select itens of a RecyclerView, so that it shows the menuitems to delete and edit, and the navigation icon to cancel the selection. This change of contents however, has to have an animation, like many apps do.

I've already checked this solution but it's a bit different from my goal (since I'm not using navigation drawer) and it's far too complicated + with not so good results.

The result should be something like this or any smooth animation: enter image description here


Solution

  • I was able to get an animation by setting android:animateLayoutChanges="true" in the toolbar's XML. I'm satisfied with how it looks even though I can't control it.