-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.ViewManager
,android.view.ViewParent
,android.view.accessibility.AccessibilityEventSource
,androidx.core.view.NestedScrollingParent
,androidx.core.view.NestedScrollingParent2
,androidx.core.view.NestedScrollingParent3
public final class ExpandableFabLayout extends CoordinatorLayout
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 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.
-
-
Field Summary
Fields Modifier and Type Field Description private OrientationConfiguration
portraitConfiguration
private OrientationConfiguration
landscapeConfiguration
private Long
overlayOpeningAnimationDurationMs
private Long
overlayClosingAnimationDurationMs
private Long
expandableFabOpeningAnimationDurationMs
private Long
expandableFabClosingAnimationDurationMs
private Long
fabOptionOpeningAnimationDurationMs
private Long
fabOptionClosingAnimationDurationMs
private Long
labelVisibleToHiddenAnimationDurationMs
private Long
labelHiddenToVisibleAnimationDurationMs
-
Constructor Summary
Constructors Constructor Description ExpandableFabLayout(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). ExpandableFabLayout(Context context, AttributeSet attributeSet)
Called by the system when creating an ExpandableFabLayout via XML (don't call this directly).
-
Method Summary
Modifier and Type Method Description final OrientationConfiguration
getPortraitConfiguration()
A holder for all the views of the ExpandableFab widget declared in the portrait screen orientation. final Unit
setPortraitConfiguration(OrientationConfiguration portraitConfiguration)
final OrientationConfiguration
getLandscapeConfiguration()
A holder for all the views of the ExpandableFab widget declared in the landscape screen orientation. final Unit
setLandscapeConfiguration(OrientationConfiguration landscapeConfiguration)
final Long
getOverlayOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the Overlays inside of this ExpandableFabLayout. final Unit
setOverlayOpeningAnimationDurationMs(Long overlayOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the Overlays inside of this ExpandableFabLayout. final Long
getOverlayClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the Overlays inside of this ExpandableFabLayout. final Unit
setOverlayClosingAnimationDurationMs(Long overlayClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the Overlays inside of this ExpandableFabLayout. final Long
getExpandableFabOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. final Unit
setExpandableFabOpeningAnimationDurationMs(Long expandableFabOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. final Long
getExpandableFabClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. final Unit
setExpandableFabClosingAnimationDurationMs(Long expandableFabClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. final Long
getFabOptionOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the FabOptions inside of this ExpandableFabLayout. final Unit
setFabOptionOpeningAnimationDurationMs(Long fabOptionOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the FabOptions inside of this ExpandableFabLayout. final Long
getFabOptionClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the FabOptions inside of this ExpandableFabLayout. final Unit
setFabOptionClosingAnimationDurationMs(Long fabOptionClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the FabOptions inside of this ExpandableFabLayout. final Long
getLabelVisibleToHiddenAnimationDurationMs()
The duration (in milliseconds as a positive long) of the visible to hidden state animations for ALL the Labels inside of this ExpandableFabLayout. final Unit
setLabelVisibleToHiddenAnimationDurationMs(Long labelVisibleToHiddenAnimationDurationMs)
The duration (in milliseconds as a positive long) of the visible to hidden state animations for ALL the Labels inside of this ExpandableFabLayout. final Long
getLabelHiddenToVisibleAnimationDurationMs()
The duration (in milliseconds as a positive long) of the hidden to visible state animations for ALL the Labels inside of this ExpandableFabLayout. final Unit
setLabelHiddenToVisibleAnimationDurationMs(Long labelHiddenToVisibleAnimationDurationMs)
The duration (in milliseconds as a positive long) of the hidden to visible state animations for ALL the Labels inside of this ExpandableFabLayout. Unit
addView(View child, Integer index, ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters to the ExpandableFabLayout. final Unit
addViews(View children)
Convenience method for adding multiple children views to the ExpandableFabLayout at once, programmatically. Unit
removeAllViews()
Removes all child views in both portrait and landscape orientation from the ExpandableFabLayout. final Unit
close()
Attempts to close the ExpandableFab, playing the appropriate animations in the process. final Boolean
isOpen()
Returns true if the ExpandableFab is currently open (any attached Overlay, FabOption and Labels are visible and all animations are done). final OrientationConfiguration
getCurrentConfiguration()
Returns the OrientationConfiguration showing for the current screen orientation. -
-
Constructor Detail
-
ExpandableFabLayout
ExpandableFabLayout(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).
-
ExpandableFabLayout
ExpandableFabLayout(Context context, AttributeSet attributeSet)
Called by the system when creating an ExpandableFabLayout via XML (don't call this directly).
-
-
Method Detail
-
getPortraitConfiguration
final 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).
-
setPortraitConfiguration
final Unit setPortraitConfiguration(OrientationConfiguration portraitConfiguration)
-
getLandscapeConfiguration
final 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).
-
setLandscapeConfiguration
final Unit setLandscapeConfiguration(OrientationConfiguration landscapeConfiguration)
-
getOverlayOpeningAnimationDurationMs
final Long getOverlayOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the Overlays inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Overlay within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY Overlays within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Overlays. If you only want to change the opening animation duration for a single Overlay, leave this property as null. See Overlay.openingAnimationDurationMs.
-
setOverlayOpeningAnimationDurationMs
final Unit setOverlayOpeningAnimationDurationMs(Long overlayOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the Overlays inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Overlay within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY Overlays within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Overlays. If you only want to change the opening animation duration for a single Overlay, leave this property as null. See Overlay.openingAnimationDurationMs.
-
getOverlayClosingAnimationDurationMs
final Long getOverlayClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the Overlays inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Overlay within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY Overlays within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Overlays. If you only want to change the closing animation duration for a single Overlay, leave this property as null and see Overlay.closingAnimationDurationMs.
-
setOverlayClosingAnimationDurationMs
final Unit setOverlayClosingAnimationDurationMs(Long overlayClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the Overlays inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Overlay within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY Overlays within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Overlays. If you only want to change the closing animation duration for a single Overlay, leave this property as null and see Overlay.closingAnimationDurationMs.
-
getExpandableFabOpeningAnimationDurationMs
final Long getExpandableFabOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every ExpandableFab within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY ExpandableFabs within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual ExpandableFabs. If you only want to change the opening animation duration for a single ExpandableFab, leave this property as null and see ExpandableFab.openingAnimationDurationMs.
-
setExpandableFabOpeningAnimationDurationMs
final Unit setExpandableFabOpeningAnimationDurationMs(Long expandableFabOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every ExpandableFab within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY ExpandableFabs within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual ExpandableFabs. If you only want to change the opening animation duration for a single ExpandableFab, leave this property as null and see ExpandableFab.openingAnimationDurationMs.
-
getExpandableFabClosingAnimationDurationMs
final Long getExpandableFabClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every ExpandableFab within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY ExpandableFabs within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual ExpandableFabs. If you only want to change the closing animation duration for a single ExpandableFab, leave this property as null and see ExpandableFab.closingAnimationDurationMs.
-
setExpandableFabClosingAnimationDurationMs
final Unit setExpandableFabClosingAnimationDurationMs(Long expandableFabClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the ExpandableFabs inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every ExpandableFab within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY ExpandableFabs within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual ExpandableFabs. If you only want to change the closing animation duration for a single ExpandableFab, leave this property as null and see ExpandableFab.closingAnimationDurationMs.
-
getFabOptionOpeningAnimationDurationMs
final Long getFabOptionOpeningAnimationDurationMs()
The duration (in milliseconds as a positive long) of the opening animations for ALL the FabOptions inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every FabOption within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY FabOptions within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual FabOptions. If you only want to change the opening animation duration for a single FabOption, leave this property as null and see FabOption.openingAnimationDurationMs.
-
setFabOptionOpeningAnimationDurationMs
final Unit setFabOptionOpeningAnimationDurationMs(Long fabOptionOpeningAnimationDurationMs)
The duration (in milliseconds as a positive long) of the opening animations for ALL the FabOptions inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every FabOption within a single ExpandableFabLayout.
Set to 0L if you don't want opening animations for ANY FabOptions within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual FabOptions. If you only want to change the opening animation duration for a single FabOption, leave this property as null and see FabOption.openingAnimationDurationMs.
-
getFabOptionClosingAnimationDurationMs
final Long getFabOptionClosingAnimationDurationMs()
The duration (in milliseconds as a positive long) of the closing animations for ALL the FabOptions inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every FabOption within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY FabOptions within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual FabOptions. If you only want to change the closing animation duration for a single FabOption, leave this property as null and see FabOption.closingAnimationDurationMs.
-
setFabOptionClosingAnimationDurationMs
final Unit setFabOptionClosingAnimationDurationMs(Long fabOptionClosingAnimationDurationMs)
The duration (in milliseconds as a positive long) of the closing animations for ALL the FabOptions inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every FabOption within a single ExpandableFabLayout.
Set to 0L if you don't want closing animations for ANY FabOptions within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual FabOptions. If you only want to change the closing animation duration for a single FabOption, leave this property as null and see FabOption.closingAnimationDurationMs.
-
getLabelVisibleToHiddenAnimationDurationMs
final Long getLabelVisibleToHiddenAnimationDurationMs()
The duration (in milliseconds as a positive long) of the visible to hidden state animations for ALL the Labels inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Label within a single ExpandableFabLayout. This property will affect Labels on ExpandableFabs AND FabOptions.
Set to 0L if you don't want visible to hidden animations for ANY Labels within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Labels. If you only want to change the visible to hidden animation duration for a single Label, leave this property as null and see Label.visibleToHiddenAnimationDurationMs.
-
setLabelVisibleToHiddenAnimationDurationMs
final Unit setLabelVisibleToHiddenAnimationDurationMs(Long labelVisibleToHiddenAnimationDurationMs)
The duration (in milliseconds as a positive long) of the visible to hidden state animations for ALL the Labels inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Label within a single ExpandableFabLayout. This property will affect Labels on ExpandableFabs AND FabOptions.
Set to 0L if you don't want visible to hidden animations for ANY Labels within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Labels. If you only want to change the visible to hidden animation duration for a single Label, leave this property as null and see Label.visibleToHiddenAnimationDurationMs.
-
getLabelHiddenToVisibleAnimationDurationMs
final Long getLabelHiddenToVisibleAnimationDurationMs()
The duration (in milliseconds as a positive long) of the hidden to visible state animations for ALL the Labels inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Label within a single ExpandableFabLayout. This property will affect Labels on ExpandableFabs AND FabOptions.
Set to 0L if you don't want hidden to visible animations for ANY Labels within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Labels. If you only want to change the hidden to visible animation duration for a single Label, leave this property as null and see Label.hiddenToVisibleAnimationDurationMs.
-
setLabelHiddenToVisibleAnimationDurationMs
final Unit setLabelHiddenToVisibleAnimationDurationMs(Long labelHiddenToVisibleAnimationDurationMs)
The duration (in milliseconds as a positive long) of the hidden to visible state animations for ALL the Labels inside of this ExpandableFabLayout. A convenience method so that clients don't have to set the same value for every Label within a single ExpandableFabLayout. This property will affect Labels on ExpandableFabs AND FabOptions.
Set to 0L if you don't want hidden to visible animations for ANY Labels within this ExpandableFabLayout.
NOTE: This property will override whatever you set on individual Labels. If you only want to change the hidden to visible animation duration for a single Label, leave this property as null and see Label.hiddenToVisibleAnimationDurationMs.
-
addView
Unit addView(View child, Integer index, 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.
-
addViews
final Unit addViews(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.
-
removeAllViews
Unit removeAllViews()
Removes all child views in both portrait and landscape orientation from the ExpandableFabLayout.
This is the only correct way to remove ALL 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.
If you only want to remove certain FabOptions, get the current OrientationConfiguration (portraitConfiguration or landscapeConfiguration or getCurrentConfiguration), then call remove(FabOption) or remove(int) (the latter is named removeAt(int) in Kotlin) on its list of FabOptions.
-
close
final Unit 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).
-
isOpen
final Boolean isOpen()
Returns true if the ExpandableFab is currently open (any attached Overlay, FabOption and Labels are visible and all animations are done).
-
getCurrentConfiguration
final 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 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.
-
-
-
-