0

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.

I want that after opening the FAB menu, when the user clicks elsewhere, the menu disappears. However, I haven't been able to find how to do this.
What listener do I need for this?

Any help?

Thanks.

amitairos
  • 2,907
  • 11
  • 50
  • 84

1 Answers1

1

You are most likely interested in a custom FloatingActionButton.Behavior:

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

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.

Jon Douglas
  • 13,006
  • 4
  • 38
  • 51
  • Thanks. How do I check via a OnTouchListener if I'm touching outside the FAB? – amitairos Jul 27 '16 at 19:06
  • 1
    http://stackoverflow.com/questions/25446855/ontouchlistener-intercept-when-touch-goes-outside-view http://stackoverflow.com/questions/6685690/android-make-view-disappear-by-clicking-outside-of-it – Jon Douglas Jul 27 '16 at 19:09