How to make this menu? This is clearly not PopupMenu or Spinner, so what is it? https://www.google.com/design/spec/components/menus.html#menus-usage

    2 answers 2

    This is the overflow menu , I do this:

     @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { SubMenu sub = menu.addSubMenu("").setIcon(R.drawable.ic_action_overflow); sub.add(Menu.NONE, 0, Menu.NONE, "Пунтк1").setIcon(R.drawable.ic_action_1); sub.add(Menu.NONE, 1, Menu.NONE, "Пункт2").setIcon(R.drawable.ic_action_2); sub.add(Menu.NONE, 2, Menu.NONE, "Пункт3").setIcon(R.drawable.ic_action_3); MenuItemCompat.setShowAsAction(sub.getItem(),MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); super.onCreateOptionsMenu(menu, inflater); } @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case 0: {} break; case 1: {} break; case 2: {} break; } return true; } 
    • This is the menu that is described here, something that does not look like a submenu or overflow menu or is it some kind of custom? - google.com/design/spec/components/menus.html#menus-usage "The label of an emitting button or control concisely and accurately measured the menu item .... "Because it is located below the sections of the menu itself and has several sections in it. - user22940
    • does not work without return and with it too. onCreateOptionsMenu - user22940
    • one
      @semiromid this code for the fragment, for activating this method looks like this: public boolean onCreateOptionsMenu(Menu menu) , about the appearance, if you use the support library(appcompat) , the menu will look exactly the same. - katso
    • katso thanks. I thought that the appearance depends on the OS version. Probably then I will use PopupWindow, it is still more custom. - user22940
    • katso - I use - com.android.support:appcompat-v7:23.1.1 '--- android.support.v7.widget.Toolbar But even if you run an Android on 5.0 OS, the socket is still not below the points themselves, but right at the very point from which it is called. Conclusion - OS version nothing to do with. - user22940

    You can directly set the xml:

      <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/file" android:icon="@drawable/file" android:title="@string/file" > <!-- "file" submenu --> <menu> <item android:id="@+id/create_new" android:title="@string/create_new" /> <item android:id="@+id/open" android:title="@string/open" /> </menu> </item> </menu> 
    • This is the menu that is described here, something that does not look like a submenu or overflow menu or is it some kind of custom? -Google.com/design/spec/components/menus.html#menus-usage "The label of an emitting button or control concisely and accurately measured the menu item .... "Because it is located below the sections of the menu itself and has several sections in it. - user22940