I have an activity that extends AppCompatActivity
I'm setting the Toolbar
this way:
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
To animate the Toolbar
icon when I open or close the NavigationView
I'm doing this:
actionBarDrawerToggle =
new ActionBarDrawerToggle(this, mNavigationDrawer, R.string.open_drawer,
R.string.close_drawer);
mNavigationDrawer.setDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
I can see that when the drawer opens the icon animates to the back arrow and when it closes, it animates from the arrow to the hamburger icon.
I want to know, without opening or closing the NavigationView
, how can I programmatically animate the icon to the arrow and back to the hamburger icon.
Something like the gmail app. If we are in the list of emails and press one email, it animates to the arrow and shows the content of the email and if we press the arrow, it animates to the hamburger and shows the list of emails.