Disable NavigationDrawer icon's slide animatio

2019-05-31 23:22发布

Is there any way to disable sliding animation of the NavigationDrawer's icon? I mean the effect, when you click the icon or open the Drawer with slide gesture. (I still use the ActionBar at the moment)

Preview

Preview

2条回答
手持菜刀,她持情操
2楼-- · 2019-05-31 23:41

You need to override the onDrawerSlide method of ActionBarDrawerToggle and set the slideOffset to 0 if the drawer is right drawer. So this would disable the animation of the navigation drawer image.

  @Override
  public void onDrawerSlide(View drawerView, float slideOffset) 
  {
        if(drawerView!=null && drawerView == rightDrawerListView){
              super.onDrawerSlide(drawerView, 0);
        }else{
              super.onDrawerSlide(drawerView, slideOffset);
        }
  }
查看更多
别忘想泡老子
3楼-- · 2019-05-31 23:53

Look at this answer. Since support v7 version 25.3.0, you can disable the animation, you can disable the animation using one line of code.

yourActionBarDrawerToggle.setDrawerSlideAnimationEnabled(false);

查看更多
登录 后发表回答