Disable NavigationDrawer icon's slide animation

主宰稳场 提交于 2019-12-10 11:34:16

问题


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


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/29351369/disable-navigationdrawer-icons-slide-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!