4

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! =)

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
  • 1
    To change the icon do this : `getSupportActionBar().setIcon()` – Josef Jan 26 '15 at 14:41
  • Hello @Josef How are you? Thanks for your answer. Do you know how to set the size of animation hamburger icon which was made by ActionBarDrawerToggle? I can`t find any information about that. How do you think is it possible? – Nurzhan Nogerbek Jan 27 '15 at 19:03

2 Answers2

11

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.

1

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));
}
craastad
  • 6,222
  • 5
  • 32
  • 46