Is possible to increase the size of ActionBarDrawerToggle (Drawer menu)?

后端 未结 4 455
梦毁少年i
梦毁少年i 2021-01-20 09:28

I followed ActionBarDrawerToggle GUIDE

And I know how to show the icon of drawer on Action Bar by using drawerImageRes in this.

p

4条回答
  •  萌比男神i
    2021-01-20 10:06

    A great answer implemented which is a slight adjustment from this https://stackoverflow.com/a/40774724/3485872

    First you want to create a custom class which extends the Drawable class which creates the hamburger and navigation icons. There are various methods to change the size of either but below are the methods which control the hamburger icon.

    public class HamburgerDrawable extends DrawerArrowDrawable{
    
    public HamburgerDrawable(Context context){
        super(context);
        setColor(context.getResources().getColor(R.color.white));
    }
    
    @Override
    public void draw(Canvas canvas){
        super.draw(canvas);
    
        setBarLength(30.0f);
        setBarThickness(5.0f);
        setGapSize(5.0f);
    
    }
    }
    

    Then to call it from your class simply use:

    private void increaseHamburgerSize(){
        mDrawerToggle.setDrawerArrowDrawable(new HamburgerDrawable(this));
    }
    

提交回复
热议问题