Hamburger menu spin to arrow on new activity
Asked Answered
R

2

12

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 back arrow).

The new activity's back arrow does not just appear as they do by default, however. The hamburger menu from the main interface spins into an arrow in an animation (see the video here: http://material-design.storage.googleapis.com/publish/material_v_3/material_ext_publish/0B3T7oTWa3HiFbFRfT196SWRyS2s/animation_delightfuldetails_wellcrafted.webm)

(Note: The newly opened email MAY be a fragment, because the toolbar doesn't change & the default new activity animation doesn't play. I'm not sure which one it is.)

Clarification: I do know how to get the hamburger menu to turn into an arrow when it's pressed/when the navigation drawer is opened. In fact, I purposefully disabled said animation because it goes against specs. (see this article: http://www.androidpolice.com/2014/10/30/google-turns-design-inconsistency-ten-latest-round-navigation-drawers/). I want to know, however, if the same animation is possible when creating a new fragment/activity, whichever one Gmail probably uses.

Rapt answered 21/4, 2015 at 14:32 Comment(1)
In my opinion GMail is using fragments. Here you can find menu drawer template with spining arrow: github.com/kanytu/android-material-drawer-template .Deandeana
D
0

If you use android.support.v7.app.ActionBarDrawerToggle it animates automatically.

Dagoba answered 21/4, 2015 at 14:46 Comment(2)
Yes, I understand that it animates automatically, at least when you pull open the navigation drawer. But I want to know if I can trigger the animation when I create a new activity/fragmentRapt
Any news on this issue? Can't seem to find anything elseCristal
B
0

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

Bilski answered 21/7, 2017 at 22:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.