简体   繁体   English

不专心时,Android隐藏FAB菜单

[英]Android Hide FAB menu when unfocused

I have a Floating Action Button with a custom menu of mini Floating Action Buttons, that appears upon click on the main Floating Action Button. 我有一个浮动动作按钮,带有一个自定义菜单的迷你浮动动作按钮,单击主浮动动作按钮后会出现。
The mini FABs are in a LinearLayout. 迷你FAB位于LinearLayout中。

I want that after opening the FAB menu, when the user clicks elsewhere, the menu disappears. 我希望在打开FAB菜单后,当用户单击其他位置时,菜单消失。 However, I haven't been able to find how to do this. 但是,我还没找到如何做到这一点。
What listener do I need for this? 我需要什么听众?

Any help? 有什么帮助吗?

Thanks. 谢谢。

You are most likely interested in a custom FloatingActionButton.Behavior : 您最可能对自定义FloatingActionButton.Behavior感兴趣:

https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.Behavior.html https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.Behavior.html

https://medium.com/@nullthemall/floatingactionmenu-floatingactionbutton-behavior-dd33cc0d9ba7#.jsvuvz2rk https://medium.com/@nullthemall/floatingactionmenu-floatingactionbutton-behavior-dd33cc0d9ba7#.jsvuvz2rk

Otherwise you can simply set the Visibility of the respective controls to Gone based on a OnTouchListener that checks if you are touching outside the FAB . 否则,您可以基于一个OnTouchListener来简单地将各个控件的Visibility设置为Gone以检查您是否在FAB之外触摸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法以编程方式隐藏圆弧菜单中的 fab 按钮。 试过 upload.hide(); 无法弄清楚如何隐藏 fab 按钮 - Unable to hide fab button in arc menu programmatically. tried upload.hide(); Not able to figure out how to hide fab button 当用户单击 SearchView 和键盘打开时如何隐藏 FAB? - How to hide FAB when user click on SearchView and Keyboard opens? 显示某些片段时无法隐藏Android溢出菜单 - Unable to Hide Android Overflow Menu When Certain Fragments Are Displayed 单击时隐藏标题,并在android的弹出菜单中显示其他标题 - Hide title when clicked and show other title on popup menu in android Android:更改未聚焦时材料暴露的轮廓下拉列表的提示文本颜色 - Android: Change hint text color for a material exposed outlined drop-down when unfocused 如何在向上滚动启动时使晶圆厂可见,而在向下滚动启动时如何隐藏晶圆厂 - How to make fab visible when scroll up starting and hide when scroll down starting 窗口未聚焦时,Java输入停止工作 - Java input stops working when window is unfocused 如何隐藏特定片段活动的“fab”丁酮? - how to hide “fab” buttone for a specific fragment activity? Android - 如何以编程方式创建FAB? - Android - How to create FAB programmatically? 如何以编程方式隐藏 Android 操作栏上的菜单? - How to programmatically hide menu on action bars in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM