I\'ve noticed that with the more recent Gmail updates for Android, when you click on one of your emails, a new Activity opens (I\'m assuming it\'s not a fragment because of the
If you use android.support.v7.app.ActionBarDrawerToggle
it animates automatically.
It too late but i put it here for upcoming questions. Gmail app opens email in a fragment.Cause you can still use hamburger menu in this page.Changing hamburger menu icon to back button i use this code and it works fine.
public void setupToolbarNavigation() {
toggle.setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
reverseToolbar();
}
});
}
public void reverseToolbar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
toggle.setDrawerIndicatorEnabled(true);
toggle.setToolbarNavigationClickListener(null);
}
toggle is instance of ActionBarDrawerToggle which you can initiate it with this code in your activity
toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
reverseToolbar change toolbar back icon to hamburger menu icon when user clicked.Declare this method in your activity and for replacing icon in fragment put this code to your fragment. ((YourActivity)getActivity()).setupToolbarNavigation