且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加快“抽屉式导航栏”动画速度上收?

更新时间:2023-01-31 08:48:19

您绝对可以调整动画的持续时间,但它会要求你拷贝过来的类从支持库,然后相应地对其进行编辑。

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持续时间在此,判断在 ViewDragHelper

然后应用到 DrawerLayout 在ViewDragHelper.smoothSlideViewTo$c$c>被称为

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

您需要创建的修改版 ViewDragHelper.forceSettleCapturedViewAt 传递一个时间参数。

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

forceSettleCapturedViewAt(... int duration)

然后创建你的版本 ViewDragHelper.smoothSlideViewTo

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

DrawerLayout

接下来,您将需要修改DrawerLayout.closeDrawer$c$c>和DrawerLayout.closeDrawers$c$c>以符合新的 ViewDragHelper 修改

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

ActionBarDrawerToggle

你还必须拷贝过来 ActionBarDrawerToggle ActionBarDrawerToggleHoneycomb 。这些文件将不需要任何编辑,但。

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