问题
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