简体   繁体   English

更改工具栏中的汉堡图标大小?

[英]Change the size of hamburger icon in toolbar?

I have 2 questions which can be strange but anyway... 我有2个问题可能很奇怪,但无论如何......

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. 我在下面的代码的帮助下制作了经典的导航抽屉(我也使用了ActionBarDrawerToggle),但如果你将它与我工具栏的其他项目(图标)进行比较,则尺寸太小。

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." “创建一个扩展Drawable类的自定义类来创建汉堡包和导航图标。有多种方法可以改变其中任何一种的大小,但下面是控制汉堡包图标的方法。”

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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