I want to have kind of pop shown in the given images. What should use ? Pop window, dialog or alert dialog. i have tried all of these, but not able to match the exact UI.
Asked
Active
Viewed 179 times
0
-
its a **[PopupMenu](https://developer.android.com/reference/android/widget/PopupMenu.html)** – Goku Jan 01 '18 at 07:49
-
"i have tried all of these, but not able to match the exact UI." Show what you have tried and what the result is, then you can get help on what to update / fix. – dominicoder Jan 01 '18 at 07:52
-
Use pop up menu more [Link](http://tutlane.com/tutorial/android/android-popup-menu-with-examples) – ND1010_ Jan 01 '18 at 07:54
-
Check my answer – Vidhi Dave Jan 01 '18 at 08:14
-
Use `popup menu/dialog` for show dialog like you want. – Prashant Jajal Jan 01 '18 at 07:49
-
You could also use Material Dialogs library its much easier and faster to implement. https://github.com/afollestad/material-dialogs – chunkydonuts21 Jan 01 '18 at 07:55
1 Answers
1
You can use Popup menu for this purpose.
Add this code in your activity.java :
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(HomeActivity.this, fab);
popup.getMenuInflater().inflate(R.menu.menu_home, popup.getMenu());
popup.setGravity(Gravity.END);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
// your action
default:
return true;
}
}
});
popup.show();
}
});
In style.xml
<style name="MyPopupMenu" parent="@style/Widget.AppCompat.PopupMenu.Overflow">
<item name="fontPath">Muli_Regular.ttf</item>
<item name="android:dropDownHorizontalOffset">0dp</item>
<item name="android:dropDownVerticalOffset">57dp</item>
</style>
use this style in activity theme as :
<item name="popupMenuStyle">@style/MyPopupMenu</item>

Vidhi Dave
- 5,614
- 2
- 33
- 55