Reputation: 671
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):
How it should look:
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.
Upvotes: 3
Views: 2624
Reputation: 11
My custom nav menu icons were too large, none of the online fixes would change the size of them. I noticed all the included AS clip art has padding on the sides...
You can load your PNG into PowerPoint for example, right click the image then choose format picture. Now increase the width and height of the crop size, you will have to guess the amount, have a look at the AS clip art to get an idea. Move the image back into the center of the crop by adjusting left and top.
Convert to SVG...
https://image.online-convert.com/convert-to-svg
Then import the vector asset.
Upvotes: 0
Reputation: 5783
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_hamburger);
res/drawable/ic_hamburger.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="13dp"
android:viewportWidth="40.0"
android:viewportHeight="25.0">
<path
android:fillColor="#2DBC99"
android:pathData="M38.5 2.999h-37a1.5 1.5 0 1 1 0-3h37a1.5 1.5 0 0 1 0 3zm-37 8h27a1.5 1.5 0 0 1 0 3.001h-27a1.5 1.5 0 0 1 0-3.001zm0 11h17a1.5 1.5 0 0 1 0 3h-17a1.5 1.5 0 1 1 0-3z" />
</vector>
Upvotes: 0
Reputation: 661
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.
Upvotes: 0