Search code examples
androidandroid-toolbar

Android toolbar setNavigationIcon not working


So, I have a BaseActivity in which I have a toolbar and I call setSupportActionBar(toolbar).

In some of my activities that extends BaseActivity, I would like to change the navigation icon (the default arrow) to another drawable. But when I call toolbar.setNavigationIcon(myDrawable) it doesn't work, it still shows the default left pointing arrow icon.

Any idea? Thanks.


Solution

  • I think you can set like this

        menuDrawerToggle = new ActionBarDrawerToggle(this, menuDrawer, toolbar, R.string.drawer_open, R.string.drawer_close){...}
    
        menuDrawerToggle.syncState();
    
        toolbar.setNavigationIcon(getResources().getDrawable(yourDrawable));
    

    put setNavigationIcon after syncState()