-1

When i added additional item to menu, it go off the screen on phone with smaller screen like 400x800. I tried to add padding but i don't want to make icon smaller but only move whole menu a little bit to the left because i see there is space for that. Does anyone has similar problem and resolve it ? enter image description here

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">
    <item
        android:id="@+id/graphic"
        android:icon="@drawable/ic_graphic_white_30dp"
        android:title="Graphic"
        app:showAsAction="always" />

    <item
        android:id="@+id/save"
        android:icon="@drawable/ic_save_white_24dp"
        android:title="@string/save"
        app:showAsAction="always" />

    <item
        android:id="@+id/share"
        android:icon="@drawable/ic_share_white_24dp"
        android:title="@string/share"
        app:showAsAction="always" />

    <item
        android:id="@+id/count"
        android:icon="@drawable/ic_pie_chart_white_24dp"
        android:title="@string/count"
        app:showAsAction="always" />
    
    <item
        android:id="@+id/camera"
        android:icon="@drawable/ic_camera_alt_white_24dp"
        android:title="@string/photo"
        app:showAsAction="always" />

    <item
        android:id="@+id/lock"
        android:icon="@drawable/ic_action_secure"
        android:title="@string/lock"
        app:showAsAction="always" />
</menu>
Tomasz Stępnik
  • 87
  • 1
  • 11
  • Means you are trying to say that if we add 100 items in menu than all 100 items should be visible? !!! – Jaimin Modi Jan 13 '21 at 09:26
  • `When i added additional item to menu, it go off the screen on phone with smaller screen` perhaps this is a sign that what you're trying to do shouldn't be done :) overflow menu's exist for a reason – a_local_nobody Jan 13 '21 at 09:27
  • 1
    Instead you can create custom *toolbar* for that and can manage space between *icons*. – Jay Rathod Jan 13 '21 at 09:28
  • Of course I'm not trying add as many item as i want, I just want to add only this one additional item, and we can see there is space for it. – Tomasz Stępnik Jan 13 '21 at 09:32
  • 1
    Instead of solving this problem. You really should change your design. It is not recommended to have more than 4 items in the Toolbar with a showAsAction as always. – jbmcle Jan 13 '21 at 09:33
  • Thank you Jake, but it's not my idea but the app owner;) – Tomasz Stępnik Jan 13 '21 at 09:38

1 Answers1

0

You can use configrations of your actionBar as below:

ActionBar mActionBar = getSupportActionBar();
mActionBar.setNavigationMode(NAVIGATION_MODE_LIST);
mActionBar.setListNavigationCallbacks(mAdapter, mNavigationCallback);

You can follow this example : Sample Here

Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72