How do I change the state of the Clans float action menu?
This is what my Clans Floating Action Menu structure looks like:
<com.github.clans.fab.FloatingActionMenu>
<com.github.clans.fab.FloatingActionButton/>
<com.github.clans.fab.FloatingActionButton/>
<com.github.clans.fab.FloatingActionButton/>
</com.github.clans.fab.FloatingActionMenu>
I
want to collapse the clan float action menu when I click one of the float action buttons. I can’t find anything on the Internet.
Similar (random):
floatingMenu.setState(FloatingActionMenu.STATE_COLLAPSED);
or
floatingMenu.setState(FloatingActionMenu.STATE_EXPANDED);
And this menu is also on the home screen of my app. So what happens is that when I press the back button to close the activity and go back to the home page again, the menu is still open, showing all the action buttons.
So I want to close (change the state of FloatingActionMenu
) the menu
.
Note: If you need more instructions, please comment below and I will attach a screenshot.
Solution
Have you tried collapsing menus with .close()
?
floatingMenu.close(true);
To collapse the fab menu after clicking the FloatingActionButton, you simply place this code in the FloatingActionButton’s onClick event.
If you want to collapse the fab menu after returning to the main activity, you can start your activity with startActivityForResult
and then override the onActivityResult on
the mainActivity and call the close function inside.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
floatingMenu.close(true);