Search code examples
javaandroidxmlmaterial-designnavigation-drawer

Navigation icon Too Large - How to resize it


I added google's material menu icon as a notification icon on the toolbar, and it appears too large. How would I resize it, or am I doing this wrong?

java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);

}

XML for toolbar:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="#00BCD4"
    android:elevation="4dp"
    android:theme="@style/ToolBarStyle"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

</android.support.v7.widget.Toolbar>

Final look (Icon is too large): Imgur

How it should look: Imgur

Thanks. Let me know If you have any other Q's.

EDIT:

Thanks for pointing that out that there's a default icon. I used that by creating an image asset, and It's the same size. Sorry for being an absolute noob, there is probably an easy way to solve this.


Solution

  • You can not resize that icon from XML or java code you can use icon which is having low resolution.your need is just to use Hamburger icon so you can download this icon from Google material design icons or you can generate by userself from Android studio that would be perfect in size To generate icon from Android studio Go to package folder right click on that you can see so many options over there you can choose image assets and you will get pop up to add icon here all the material design icon will be there you can customise icons according to your need.