Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open navigation drawer with animation at startup

I implemented navigation drawer as described here in android developer portal. And everything works fine. Now I read android guidlines here. In section "Introduce the user to the drawer at first use" there is described I should open the drawer when application launches first. Now my idea for implementing this is to open the drawer after opening the app (and maybe close it again).

Now I tried to call myDrawer.openDrawer(Gravity.LEFT) in onCreate and the drawer is open when the app launches, but there's no animation. So onCreate seems to be the wrong place. Where should I place the call to openDrawer to let the user see the animation?

like image 737
Martin H. Avatar asked Dec 03 '25 04:12

Martin H.


1 Answers

I guess you can do this by delaying the animation. For example:

@Override
protected void onResume() {
    super.onResume(); 

    myDrawer.postDelayed(new Runnable() {
        @Override
        public void run() {
            myDrawer.openDrawer(Gravity.LEFT)
        }
    }, 1000);
}

However the fact that the Android Guidelines suggests the drawer to be opened when the application launches for the first time, does not imply it should be animated.

like image 82
Andy Res Avatar answered Dec 04 '25 20:12

Andy Res



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!