Package 

Class FabOption

  • All Implemented Interfaces:
    android.graphics.drawable.Drawable.Callback , android.view.KeyEvent.Callback , android.view.accessibility.AccessibilityEventSource , androidx.coordinatorlayout.widget.CoordinatorLayout.AttachedBehavior , androidx.core.view.TintableBackgroundView , androidx.core.widget.TintableImageSourceView , com.google.android.material.expandable.ExpandableTransformationWidget , com.google.android.material.expandable.ExpandableWidget , com.google.android.material.shape.Shapeable

    
    public final class FabOption
    extends FloatingActionButton
                        

    The design and behavior of a single option within an ExpandableFab.

    Developer Notes:

    • Layout_width and layout_height should be set to wrap_content, unless you're setting custom dimensions.

    • FabOptions must be defined within an ExpandableFabLayout to function properly.

    • label.labelText must be non-null for the optional label to show and other label properties to take effect.

    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.

    • Constructor Detail

      • FabOption

        FabOption(Context context, Orientation orientation)
        Used to create a FabOption programmatically (do not use the other constructor FabOption(context, attributeSet) - it is for use by the Android framework when inflating a FabOption via XML).
      • FabOption

        FabOption(Context context, AttributeSet attributeSet)
        Called by the system when creating a FabOption via XML (don't call this directly).
    • Method Detail

      • getFabOptionColor

         final Integer getFabOptionColor()

        The color of the FabOption, as an integer in the form 0xAARRGGBB.

        If using an XML resource color value, retrieve it in the correct form by calling: ContextCompat.getColor(context, R.color.name_of_color_resource).

        Default value is the colorAccent value defined in your app theme (styles.xml). If colorAccent is not defined in your app theme, colorSecondary may be used.

        Usage of this property is preferred over the inherited setBackgroundColor and backgroundTintList methods.

      • getFabOptionIcon

         final Drawable getFabOptionIcon()

        The drawable to show as the FabOption's icon. Default value is null (no icon shown).

        Usage of this property is preferred over the inherited set/getImageXXX methods.

      • getFabOptionEnabled

         final Boolean getFabOptionEnabled()

        The enabled state of this FabOption and its label. Disabled FabOptions and labels will be visually distinct and unclickable. Default value is true (enabled).

        Usage of this property is preferred over the inherited is/setEnabled methods.

        NOTE: If you disable a FabOption and its label, remember to re-enable it before trying to update one of its properties. For example, disabling a FabOption then manually changing its background color will not automatically re-enable the FabOption. It, and its label, will remain disabled.

      • getOpeningAnimationDurationMs

         final Long getOpeningAnimationDurationMs()

        The duration (in milliseconds as a positive long) of the animations that will be played when this FabOption is being shown from a hidden state (when the ExpandableFab is opening). Set to 0L if you don't want opening animations played. Default value is 125L.

      • getClosingAnimationDurationMs

         final Long getClosingAnimationDurationMs()

        The duration (in milliseconds as a positive long) of the animations that will be played when this FabOption is being hidden from a visible state (when the ExpandableFab is closing). Set to 0L if you don't want closing animations played. Default value is 75L.

      • getOpeningOvershootTension

         final Float getOpeningOvershootTension()

        The tension (as a positive float) in an OvershootInterpolator applied on the FabOption when it's playing its animations for being shown from a hidden state (when the ExpandableFab is opening). The OvershootInterpolator allows us to have an animation where the FabOption will grow past its regular size when initially appearing, before smoothly shrinking down to regular size. Larger values will exaggerate the effort more. Default value is 3.5f.

      • getLabel

         final Label getLabel()

        The optional label attached to this FabOption. The label will only be shown when its labelText is not null. Default values for the label are as follows:

        labelText = null labelTextColor = white labelTextSize = 14sp labelFont = Typeface.DEFAULT labelBackgroundColor = gray (#333333) labelElevation = 6dp position = LabelPosition.LEFT marginPx = 50f translationPx = 100f visibleToHiddenAnimationDurationMs = 75L hiddenToVisibleAnimationDurationMs = 250L overshootTension = 3.5f

      • setOnClickListener

         Unit setOnClickListener(View.OnClickListener onClickListener)

        Registers a callback to be invoked when this FabOption or its label is clicked. The default behavior the FabOption will be executed before this custom callback.

        Note: Only one FabOption can be clicked per ExpandableFab opening or closing animation. For example, if you set long durations on the opening animations of the ExpandableFab, then the first clicked FabOption will fire its onClickListener, and all subsequent clicks to this or other FabOptions will be ignored until the ExpandableFab has completely finished its animation (this is to prevent a user from spam clicking multiple FabOptions during long animations).