Search code examples
androidandroid-layoutandroiddesignsupport

How to animate the hamburger icon to back arrow while using design support library?


Hello I am using the most recent support library from android called design support library and using the NavigationView in it for shwing drawer. But the problem is when I am openning my drawer my hamburger icon doesnt spins into a back arrow icon, it always remains the same, but I can remember that when I used the drawerlayout without the support library it spinned automatically, here is my last try that I did:

dl.setDrawerListener(new ActionBarDrawerToggle(this, dl, tb, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);

                supportInvalidateOptionsMenu();
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                supportInvalidateOptionsMenu();
            }

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                super.onDrawerSlide(drawerView, slideOffset);

            }
        });

but nothing happeded, is there any short trick or tips that I am mising here?


Solution

  • I have solved my problem by this, Actually I was using a method to hard set the hamburger icon as the actionbar icon using this code:

    ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    

    I have just commented out this line of code and then it worked.