Speed up ‘Navigation Drawer’ animation speed on closing?

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.

ViewDragHelper

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);
    }

DrawerLayout

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

ActionBarDrawerToggle

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

Leave a Comment