0

I have a custom icon here and I want it to become smaller.

This is my xml menu code:

<?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">

    <group android:id="@+id/main_page">
        <item

            android:id="@+id/main_page_search"
            android:state_focused="true"
            android:icon="@drawable/magnify"
            app:showAsAction="always"
            android:title="Search" />
        <item
            android:id="@+id/main_page_check_cart"
            android:icon="@drawable/shopping"
            android:state_focused="true"
            app:showAsAction="always"
            android:title="Check cart" />
    </group>

</menu>

My xml layout view:

enter image description here

Cena
  • 3,316
  • 2
  • 17
  • 34
PAkultie
  • 102
  • 1
  • 11

2 Answers2

0

set below for each item to for instance 25dp;

android:layout_width and android:layout_height

like

<item

        android:id="@+id/main_page_search"
        android:layout_width = "20dp"
        android:layout_height = "20dp"
        android:state_focused="true"
        android:icon="@drawable/magnify"
        app:showAsAction="always"
        android:title="Search" />
Trajox
  • 352
  • 3
  • 11
  • ive try taht one sir, no errors found but not working... i did'nt know if my drawable size is the problem... – PAkultie Oct 08 '19 at 02:40
0

you can try this if u want use menu to navigation

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

or you can try customs toolbar and your style set no action bar

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:contentInsetStart="16dp"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|center_vertical"
            android:layout_marginEnd="16dp"
            android:background="@drawable/button_menu"
            app:srcCompat="@drawable/ic_search"
            tools:ignore="ContentDescription" />

        <ImageView
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_gravity="end|center_vertical"
            android:background="@drawable/button_menu"
            app:srcCompat="@drawable/ic_search"
            tools:ignore="ContentDescription" />

    </androidx.appcompat.widget.Toolbar>

</LinearLayout>

style no action bar like this

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

enter image description here