user3737339
user3737339

Reputation: 231

How to get popup menu from bottom of screen?

I'm going on with my contacts list for that I need a popup menu should appear to get contacts I got the popup menu and options with the help of below code:

 PopupMenu popup = new PopupMenu(SettingsPage.this, dropdown);
    // Inflating the Popup using xml file
    popup.getMenuInflater().inflate(R.menu.contactmenu, popup.getMenu());

    // registering popup with OnMenuItemClickListener
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    public boolean onMenuItemClick(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.contacts:
{
// my activity
}

    default:
    return false;
    }

    }
    });

    popup.show();  */
    // showing popup menu
     }

But my problem was popup appears just below the button what I need was to get the popup in the bottom of screen is it possible to get it.

If anyidea about this please help me friends.

Upvotes: 1

Views: 2665

Answers (1)

João Marcos
João Marcos

Reputation: 3972

If i understand you cannot use a PopupMenu for this purpose.

As docs say:

A PopupMenu displays a Menu in a modal popup window anchored to a View. The popup will appear below the anchor view if there is room, or above it if there is not. If the IME is visible the popup will not overlap it until it is touched. Touching outside of the popup will dismiss it.

You may want to try to use PopupWindow perhaps, which allows such positioning.

Upvotes: 1

Related Questions