[英]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.