How to create menu on Android?

Asked

Viewed 4,514 times

-2

I’m looking to create a menu similar to this:

inserir a descrição da imagem aqui

Would anyone like to tell me how to ride? I would like some tips.

  • Please do not use this menu, because I believe that this is a design ultrapassado and I don’t recommend it. Here’s a way to create it your way: http://www.androidhive.info/2011/09/how-to-create-android-menus/

  • @Reiksiel What do you mean by outdated design? The example you quoted goes according to what it says to official documentation, which by the way was where the OP took the image he gave as an example.

2 answers

4

Are you having any specific difficulty? Otherwise, just create a file res/menu/menu.xml with menu items having each item a title and a drawable icon, as exemplified in own documentation:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/new_game"
          android:icon="@drawable/ic_new_game"
          android:title="@string/new_game"
          android:showAsAction="ifRoom"/>
    <item android:id="@+id/help"
          android:icon="@drawable/ic_help"
          android:title="@string/help" />
</menu>

On devices that do not have a physical menu button, it is recommended that you add a Action Bar to your activities and use the virtual action overflow button (item 3 of this image) as a menu button.

  • I am wanting to create how from the image put the menu items one next to the other type 2x2

  • @Guilherme I think this is mounted by Android automatically as the available space on the screen, I’m not aware of any settings to define how the items will appear except in order.

2


William is exactly what @Piovezan said the android itself adjusts the amount according to the screen, but take a look here Implementing Navigation in the Android documentation itself.

Because this menu uses the "menu" button of the device and nowadays several models no longer have. With this can generate navigation problems with the user.

The models of Motorola and some Galaxy Tab with Android 4.x are already without this button.

Exemplo Menu

In the new template you can create a menu like this:

Here in the group android has a discussion about, and more links also.

It’s worth a try.

  • In some templates the menu button is replaced by the virtual overflow action button (item 3 of this image). To make this button available to the user you need your activities to have a Action Bar. This is a possible trend in other devices, but the menu functionality should always exist somehow in the user interface, even without the physical button.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.