cascade¶
cascade
offers a drop-in replacement for PopupMenu. For guidance on creating & nesting menus, the official documentation can be followed while replacing any usages of PopupMenu
with CascadePopupMenu
.
- val popup = PopupMenu(context, anchor)
+ val popup = CascadePopupMenu(context, anchor)
popup.inflate(R.menu.nicolas_cage_movies)
popup.show()
Consistency with Toolbar's overflow menu¶
Toolbar
uses PopupMenu
for showing overflow menu without offering any way to change this. If you're replacing all PopupMenu
usages in your project with cascade
, there are a few ways you could achieve consistency by forcing Toolbar
to use cascade
:
-
The safest way is to extract out your toolbar menu items with
app:showAsAction="ifRoom"
into their own menu that is shown usingcascade
manually. -
Alternatively,
cascade
offers an override using reflection but is currently incompatible with Proguard: