Reputation: 209
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.
Upvotes: 4
Views: 17595
Reputation: 209
Finally, i used @ShivaSnape 's method, and it works for me.
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/colorPrimary">
<ImageView
android:id="@+id/img_qrorrfid"
android:layout_gravity="end"
android:layout_width="112dp"
android:layout_height="44dp"
android:scaleType="centerInside"
android:src="@mipmap/scan_qr"/>
</android.support.v7.widget.Toolbar>
Upvotes: 0
Reputation: 2785
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>
Upvotes: 3