The material design floating action button is a powerful tool for promoting an action within your application. Quite
a few Codename One developers implemented with own interpretation of this UI element and with the coming update
we will have an official implementation.
FloatingActionButton is a round button that resides on top of the UI typically in the bottom right hand side.
It has a drop shadow to distinguish it from the UI underneath and it can hide two or more additional actions under
the surface. E.g. we can create a simple single click button such as this:
FloatingActionButton fab = FloatingActionButton.createFAB(FontImage.MATERIAL_ADD); fab.addActionListener(e -> ToastBar.showErrorMessage("Not implemented yet...")); fab.bindFabToContainer(form.getContentPane());
Which will place a
+ sign button that will perform the action. Alternatively we can create a nested action
where a click on the button will produce a submenu for users to pick from e.g.:
FloatingActionButton fab = FloatingActionButton.createFAB(FontImage.MATERIAL_ADD); fab.createSubFAB(FontImage.MATERIAL_PEOPLE, ""); fab.createSubFAB(FontImage.MATERIAL_IMPORT_CONTACTS, ""); fab.bindFabToContainer(form.getContentPane());
Those familiar with this widget know that there are many nuances to this UI that we might implement/expose
in the future. At the moment we chose to keep the API simple and minimal for the common use cases and refine
it based on demand.