How to change the size of menu item icon in NavigationView?

前端 未结 5 1013
无人及你
无人及你 2020-12-25 10:21

I have the following menu item:


   
            


        
5条回答
  •  庸人自扰
    2020-12-25 10:58

    The main thing that decide the icon's size is the dimension:navigation_icon_size, have a look at the NavigationMenuItemView class:

     public NavigationMenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mIconSize = context.getResources().getDimensionPixelSize(dimen.navigation_icon_size);
    }
    

    so, we can just overide the property in our dimens file.

    For example:

    48dp
    

    add that code in the dimens file, and you can find it's size changed.

    Before:

    After:

提交回复
热议问题