public class ExpandableFabLayout
The container and controller for all children views of the ExpandableFab widget (Overlay, ExpandableFab, FabOption, Label). The ExpandableFabLayout handles the bulk of the functionality for the ExpandableFab widget as a whole (from coordinating opening and closing animations to screen orientation changes, etc). See below for an example on how to easily set up the ExpandableFab widget using the ExpandableFabLayout as the containing ViewGroup.
Protip: If you only set a single ExpandableFab widget, it will automatically be used for both portrait and landscape orientations. No need to set duplicate views if you would like the same widget in both orientations. If you would like two different widgets for portrait and landscape however, you can do so by explicitly defining different orientations for the different sets of widget views. In the example below we don't set orientation for any of the views, so they default to 'portrait'. However, since we didn't explicitly set landscape views, the widget will actually be used for both portrait and landscape.
ExpandableFab widget Example via XML:
Developer Notes:
The ExpandableFabLayout should be given a layout_width and layout_height of match_parent,
and it should be a child of a ViewGroup that has access to draw over the full screen as well.
This is necessary as some views of the widget (like the class Overlay
) may need the ability to draw
over the full screen. Setting the dimensions as such will not impede the viewability,
clickability or focusability of any other views in your layout.
Implementation Notes:
Since the Kotlin 'internal' modifier translates to 'public' in Java, the JvmSynthetic annotation is used on those functions and properties to hide them from the published API for Java clients. A proper solution to this issue would be a package-private visibility modifier, but Kotlin has yet to implement it (https://youtrack.jetbrains.com/issue/KT-29227). Until then, the JvmSynthetic annotations should remain in order to present the proper published API to both Java & Kotlin clients.
class Overlay
,
JvmSyntheticpublic ExpandableFabLayout(@NotNull android.content.Context context)
Used to create an ExpandableFabLayout programmatically (do not use the other constructor ExpandableFabLayout(context, attributeSet) - it is for use by the Android framework when inflating an ExpandableFabLayout via XML).
public ExpandableFabLayout(@NotNull android.content.Context context, @NotNull android.util.AttributeSet attributeSet)
Called by the system when creating an ExpandableFabLayout via XML (don't call this directly). To create an ExpandableFabLayout programmatically, use the ExpandableFabLayout(context) constructor.
@NotNull public OrientationConfiguration getPortraitConfiguration()
A holder for all the views of the ExpandableFab widget declared in the portrait screen orientation. Values for the views will only be populated after they are added through calls to ExpandableFabLayout's addView methods (or after they're defined via XML).
@NotNull public OrientationConfiguration getLandscapeConfiguration()
A holder for all the views of the ExpandableFab widget declared in the landscape screen orientation. Values for the views will only be populated after they are added through calls to ExpandableFabLayout's addView methods (or after they're defined via XML).
public void addView(@Nullable android.view.View child, int index, @Nullable android.view.ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters to the ExpandableFabLayout.
In general, only Overlay, ExpandableFab, FabOption, and specific Material Design views (like Snackbar and BottomAppBar) should be added as children of the ExpandableFabLayout.
While this library won't stop you from adding in other types as direct children to the ExpandableFabLayout, please know adding other View types may cause visual issues.
public void addViews(@NotNull android.view.View... children)
Convenience method for adding multiple children
views to the ExpandableFabLayout at once,
programmatically. Ensure your children views are of type Overlay, ExpandableFab or FabOption
only.
children
public void removeAllViews()
Removes all child views in both portrait and landscape orientation from the ExpandableFabLayout.
This is the only correct way to remove views from your ExpandableFab widget should you choose to reuse the same ExpandableFabLayout instead of instantiating a new one. Using any other removeView variation will provide no guarantees of proper internal state control, and thus could potentially lead to Exceptions during runtime.
public void close()
Attempts to close the ExpandableFab, playing the appropriate animations in the process. If the ExpandableFab is not in a position to close (it's still playing its opening animations), it will remind itself to close once it is able.
Safe to call even when no ExpandableFab is open (will do nothing).
public boolean isOpen()
Returns true if the ExpandableFab is currently open (any attached Overlay, FabOption and Labels are visible and all animations are done).
@NotNull public OrientationConfiguration getCurrentConfiguration()
Returns the OrientationConfiguration showing for the current screen orientation.
An OrientationConfiguration is just a holder for all the views of an ExpandableFab widget
in a specific enum Orientation
.
Should only be called after you have added the views to an ExpandableFabLayout programmatically via the addView methods, or declared them within an ExpandableFabLayout via XML. Otherwise, the views contained may be null for references or empty for lists.
Although the portraitConfiguration
and landscapeConfiguration
properties are both exposed
publicly for clients to obtain directly, this method allows you to retrieve the correct
set of views without first knowing what screen orientation the device is currently in.
Note: This method will automatically take into account orientations with no configuration set. That is, if you only set a portrait configuration, then this method will pass back that configuration even if the device is currently in landscape. You don't have to worry about being given an OrientationConfiguration for an orientation that you did not set.