How to make a menu of options at the bottom of the Android screen

So here is what I am trying to implement; when people click on the menu in the upper right corner of the toolbar, the options menu appears at the bottom of the screen. This is similar to the picture below.

enter image description here

I'm not sure which method I should call for the element below. Can someone give me some hint on how to implement this?

The icon in the upper right menu bar, I successfully implement the code below. But I don't know how to show options at the bottom of the screen with match_parent width and wrap_content height

onClick in the upper right corner

  @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.edit_profile_image_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.more: //How to show the 2 option in the bottom of screen here return true; } return super.onOptionsItemSelected(item); } 

Update After implementing the Nikesh code, a pop-up window is shown as

enter image description here

+5
source share
1 answer

try this plug this pop-up menu in your click event to view bootom as a button click event

step 1 create a view when loading your layout, for example

 <View android:layout_gravity="center" android:id="@+id/myView" android:layout_width="match_parent" android:layout_height="wrap_content"/> 

step 2 create a new_menu.xml file like this

 <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/temp" android:title="@string/str_menu_account_logout" android:icon="@drawable/next" app:showAsAction="ifRoom"></item> </menu> 

now add this code to create a options menu in your java file

 @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.new_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.temp) { PopupMenu popupMenu = new PopupMenu(this, findViewById(R.id.myView),Gravity.CENTER); popupMenu.inflate(R.menu.home_menu); popupMenu.show(); return true; } return false; } 
+1
source

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


All Articles