Search code examples
androidhamburger-menuactionbardrawertoggle

how to change actionbar hamburger icon to back icon (with animation) from activity


No, its not a re asked question I've searched so well. but nowhere found how to do this. I want to change the hamburger icon to back icon by calling a method from my activity. I can do it with Drawer.. but I wanna do it without opening drawer.. for example, when a fragment is shown.. the hamburger will turn into back arrow(with animation) then clicking the back arrow will hide fragment and turn the arrow back into hamburger.

I want the animation while doing this.. is there any way to do that? or its only possible while opening/closing drawer

Thanks in advance


Solution

  • I did it by Calling

    onDrawerSlide(View v, float f);
    

    where float value from 0.0f to 1.0f defines the progress of transforming from hamburger to back arrow.

    Then I used object animator to call this method 100 times each time float value 0.1 increased and the magic happened. Thank you @gauravsarma for showing me the way.