Nothing appears in the Android Options menu

I created an options menu with an icon that I made myself (24px x 24px), but it does not appear.

The code in my xml (located in res / menu) is as follows:

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_insert" android:icon="@drawable/menu_add" android:title="@string/menu_insert" /> </menu> 

The menu is created in the Activity.java file, as indicated in the documentation:

 public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.list_menu, menu); return true; } 

PS The title of the element is located all the way to the left, and I can not find anywhere in the documentation how to center it (apparently, android: gravity does not work there)

thanks

+6
source share
1 answer

I think your call to super.onCreateOptionsMenu(menu) should be removed, it is not needed and it seems to change your menu.

-1
source

Source: https://habr.com/ru/post/910859/


All Articles