问题描述
我需要创建某种类型的快速操作菜单,每当用户单击按钮时,该菜单就会出现在所单击项目(按钮)的右侧.
I need to create some type of quick action menu that appears to the right side of the clicked item (button) whenever the user clicks the button.
这是我要实现的目标的示例:
Here's an example of what I'm trying to achieve:
当用户单击 button1 时,我希望子快速操作菜单"显示为如上图所示.无论如何,是否可以在 android 中本地"执行此操作?
When the user clicks button1 I want the "sub quick action menu" to appear like it's shown in the image above.Is there anyway to do this 'natively' in android?
我找到了这个插件,但它只允许您从按钮的顶部或底部显示菜单.https://github.com/lorensiuswlt/NewQuickAction3D
I have found this plugin but it only allows you to show the menu from the top or bottom of the button.https://github.com/lorensiuswlt/NewQuickAction3D
推荐答案
正如 tyczj 所说,您可以使用 PopupMenu 来实现.这个想法是弹出菜单将包含所有元素的自定义视图膨胀,背景为 9 个补丁图像.
这是一篇博文,展示了如何做到这一点.希望能帮到你.
As tyczj said, you could achieve that with a PopupMenu. The idea is that the popup menu will inflate a custom view with all the elements, having as background a 9 patch image.
Here's a blog post that shows how to do that. Hope it will help you.
这篇关于Android:创建快速操作菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!