xBroak xBroak - 1 year ago 367
Android Question

Speed up 'Navigation Drawer' animation speed on closing?

Implemented and working as expect, as such there really is no code that is worth posting here, simply looking to find out if anyone has experience with speeding up the time it takes the drawer to open and close? The YouTube app for instance is much faster!

Answer Source

You can definitely adjust the duration of the animation, but it will require you to copy over the classes from the support library, then edit them accordingly.


The duration is determined here in ViewDragHelper

Then is applied to the DrawerLayout when ViewDragHelper.smoothSlideViewTo is called

You'll need to create a modified version of ViewDragHelper.forceSettleCapturedViewAt that passes in a duration param.

forceSettleCapturedViewAt(... int duration)

Then create your version of ViewDragHelper.smoothSlideViewTo.

public boolean smoothSlideViewTo(... int duration) {
        return forceSettleCapturedViewAt(... int duration);


Next you'll need to modify DrawerLayout.closeDrawer and DrawerLayout.closeDrawers to match your new ViewDragHelper modifications.


You'll also have to copy over ActionBarDrawerToggle and ActionBarDrawerToggleHoneycomb. These files won't require any editing though.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download