简体   繁体   中英

Change the size of hamburger icon in toolbar?

I have 2 questions which can be strange but anyway...

I have toolbar with a title of application. How to change it to picture which is not the logo?

The next question: Is it possible to set, change the size of hamburger icon in toolbar? I made classic navigation drawer with the help of next code below (I used ActionBarDrawerToggle also) but the size is too small if you will compare it with another items(icons) of my toolbar.

toolbar = (Toolbar) findViewById(R.id.application_toolbar);
setSupportActionBar(toolbar);

getSupportActionBar().setDisplayShowHomeEnabled(true);

NavigationDrawerFragment drawerFragment = (NavigationDrawerFragment)getFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer,(DrawerLayout)findViewById(R.id.drawer_layout), toolbar );

Thanks for any help! =)

I had solved this problem by this way:

for (int i = 0; i < mToolbar.getChildCount(); i++) {
   if(mToolbar.getChildAt(i) instanceof ImageButton){
       mToolbar.getChildAt(i).setScaleX(1.5f);
       mToolbar.getChildAt(i).setScaleY(1.5f);
   }
}

and my hamburger icon size had been increased.

I wanted to increase the size of the Hamburger button and found other answers to not work. Code from this answer worked perfectly and is pasted below.

"Create a custom class which extends the Drawable class to create 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 call it from your class:"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM