Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change menu icon size on toolbar?

This is my menu.xml file:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/men_item_scan"
          android:title="@null"
          android:icon="@mipmap/scan_qr"
        app:showAsAction="always"/>
</menu>

and question is how can i change the size of the icon? the scan_qr.png's size is 224*89 but it's so small when the app is running on my phone.

like image 204
archerLj Avatar asked Sep 03 '25 15:09

archerLj


1 Answers

Use drawable instead

Try as fallow

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/men_item_scan"
          android:title="@null"
          android:icon="@drawable/scan_qr"
        app:showAsAction="always"/>
</menu>

drawable/scan_qr.xml change width and height

<vector android:height="24dp" android:width="24dp"
    android:tint="#FFFFFF"
    android:viewportHeight="24.0" android:viewportWidth="24.0"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FF000000" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
    <path android:fillColor="#FF000000" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>
like image 70
Abner Escócio Avatar answered Sep 05 '25 15:09

Abner Escócio