0

I try to finish my Toolbar, but the icon size of whatever icon I use is a bit too large in comparison to the "settings"-dots as well as the search icon in my Toolbar. I tried to change the size manually with GIMP, however Android Studio still scales up the icons to the previous size.

screenshot of the issue

Here is my XML for the menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:icon="@drawable/icon_notification_white"
    android:id="@+id/sv_toolbar_main"
    app:showAsAction="always"
    app:actionViewClass="android.support.v7.widget.SearchView"
    android:title="Search"
    />

<item
    app:showAsAction="ifRoom"
    android:id="@+id/iv_toolbar_main_notifications"
    android:icon="@drawable/icon_add_notifier"
    android:title="notifications"
    />

<item
    android:id="@+id/toolbar_settings"
    android:title="Settings"
    app:showAsAction="never"
    android:orderInCategory="1"/>

</menu>

and here is my relevant onCreate code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.main);
    setSupportActionBar(toolbar);

In onCreateOptionsMenu I only made changes to the searchView in the toolbar:

    @Override
public boolean onCreateOptionsMenu(final Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        mSearchViewToolbar = menu.findItem(R.id.sv_toolbar_main);
        SearchView searchViewAction = (SearchView) MenuItemCompat.getActionView(mSearchViewToolbar);
        searchViewAction.setIconifiedByDefault(true);
        searchViewAction.setMaxWidth(Integer.MAX_VALUE);
        searchViewAction.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
            }

            @Override
            public boolean onQueryTextChange(String arg0) {
                cursorFilter = !TextUtils.isEmpty(arg0) ? arg0 : null;
                getSupportLoaderManager().restartLoader(ID_LOADER_MAIN, null, MainActivity.this);
                return true;
            }
        });
        return super.onCreateOptionsMenu(menu);
}

how can i adjust the size of an icon or increase the size of the other icons?

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
samYemmY
  • 13
  • 5
  • Have a look at: https://stackoverflow.com/questions/31679320/how-to-change-android-top-toolbar-menu-item-icon-size – merterpam Oct 14 '17 at 14:11
  • can't find a solution for my problem there though – samYemmY Oct 14 '17 at 14:35
  • I was thinking creating a custom layout with top/bottom margins would work. Another solution could be adding margins to the icon itself with GIMP. As a last solution, you can make a custom toolbar and have more control by using an ImagveView. – merterpam Oct 14 '17 at 15:53
  • thanks man! I used the GIMP workaround – samYemmY Oct 16 '17 at 13:24

0 Answers0