1

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

marson
  • 913
  • 10
  • 32

2 Answers2

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);
        }
  }
Apurva
  • 7,871
  • 7
  • 40
  • 59
  • Works, but i deleted the "drawerView == rightDrawerListView" part of the if-else statement. What do you mean by "rightDrawerListView" ? – marson Mar 30 '15 at 16:40
  • Actually I wrote the code from my project, I'm pulling the Navigation Drawer from right side. `drawerView == rightDrawerListView` is used to disable animation if it is pulled from right side. [Check this](http://stackoverflow.com/questions/17156340/android-is-navigation-drawer-from-right-hand-side-possible) if you want Navigation Drawer at the right side. – Apurva Mar 30 '15 at 19:12
0

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

Ramiz Raja
  • 300
  • 6
  • 17