禁用汉堡包到箭头动画

Disable hamburger to arrow animation

我正在尝试使用 android v7 支持库实现双抽屉布局。我在左侧 (Gravity.START) 有一个导航抽屉,在右侧 (Gravity.END) 有一个通知抽屉。问题是,当拉出通知抽屉时,我需要操作栏中的汉堡包保持汉堡包,但如果拉出导航抽屉,则保持动画并更改为箭头。目前,当其中一个被拉出时,它会变成一个箭头。我已经通过覆盖 onDrawerSlide(View, float) 成功地禁用了动画,如果视图是导航抽屉则只调用 super.onDrawerSlide(View, float) 并且如果视图是通知抽屉则什么也不做,如下所示:

@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    // Make sure it was the navigation drawer
    if(drawerView.equals(navigationDrawer)) {
        super.onDrawerSlide(drawerView, slideOffset);
    }
    else {
        // Do nothing
    }
}

但是,通知抽屉完全打开后,图标仍变为箭头。知道如何禁用此更改吗?

除了处理 onDrawerSlide 你还需要处理 onDrawerOpenedonDrawerClosed:

@Override
public void onDrawerOpened(View drawerView, float slideOffset) {
    // Make sure it was the navigation drawer
    if(drawerView.equals(navigationDrawer)) {
        super.onDrawerOpened(drawerView, slideOffset);
    }
    else {
        // Do nothing
    }
}

@Override
public void onDrawerClosed(View drawerView, float slideOffset) {
    // Make sure it was the navigation drawer
    if(drawerView.equals(navigationDrawer)) {
        super.onDrawerClosed(drawerView, slideOffset);
    }
    else {
        // Do nothing
    }
}

上面接受的答案对我不起作用,但下面的答案对我有用

@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    super.onDrawerSlide(drawerView, 0); // this disables the animation 
}

由于支持v7版本25.3.0,可以关闭动画

yourActionBarDrawerToggle.setDrawerSlideAnimationEnabled(false);