I want to use the approach: "each fragment has its own Toolbar ".
As in this case, correctly implement the morph animation
Hamburger -> BackButton
during transitions between fragments?

    2 answers 2

    You get this situation: the Toolbar belongs to the fragment, and the icon inside the Toolbar displays the status of the stack of fragments inside the activation.

    If you really need this animation of the transition from a hamburger to an arrow, then there are two options:

    1) Make global Toolbar in activit. But then there will be all the flowing cases with the inflite of different menus and titles from specific fragments.

    2) Do in the activation method that synchronizes the passed Toolbar with the state of the stack. But we must not forget to disconnect the Toolbar when the fragment leaves the screen (it is logical to use the start / stop methods)

     fun attachToolbarNavigationIcon(toolbar: Toolbar) {} fun dettachToolbarNavigationIcon() {} 

    PS: There is a simpler option. Most likely the animation from the "hamburger" in the "back" button you need only when moving from the first fragment to the next. In other cases, only the "back" button hangs there.
    Therefore, it is possible to process this only within the framework of the first fragment and that’s all: before going forward, we turn it into a back button and only then proceed.
    When you return, turn back into a hamburger.

      I can not give you a ready-made solution, but in the general case, the support library has a ready-made class DrawerArrowDrawable , which implements this morphing icon. You can always try to add it to your Toolbar and start the animation after the toolbar of the new fragment is added to the screen. An example of starting the animation here .

      If you use Navigation Drawer, the icon should work out of the box. Here there is a similar question with answers, how to use different toolbars (pay attention not only to the accepted answer, but also to the answer with a majority vote).