library / com.nambimobile.widgets.efab / FabOption

FabOption

class FabOption : FloatingActionButton

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

Developer Notes:

  1. Layout_width and layout_height should be set to wrap_content, unless you're setting custom dimensions.
  2. FabOptions must be defined within an ExpandableFabLayout to function properly.
  3. label.labelText must be non-null for the optional label to show and other label properties to take effect.

Implementation Notes:

  1. 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.

Since
1.0.0

Constructors

<init>

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). This constructor keeps all optional properties of a FabOption at their default values, though you can always change these values after instantiation by using the appropriate setter methods (with the exception of orientation, which cannot be changed after instantiation).

FabOption(context: Context, orientation: Orientation? = Orientation.PORTRAIT)

Called by the system when creating a FabOption via XML (don't call this directly). To create a FabOption programmatically, use the FabOption(context, orientation) constructor.

FabOption(context: Context, attributeSet: AttributeSet)

Properties

closingAnimationDurationMs

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). Default value is 75L.

var closingAnimationDurationMs: Long

fabOptionColor

The color of the FabOption. Default value is your app's colorAccent.

var fabOptionColor: Int

fabOptionEnabled

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

var fabOptionEnabled: Boolean

fabOptionIcon

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

var fabOptionIcon: Drawable?

label

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:

val label: Label

openingAnimationDurationMs

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). Default value is 125L.

var openingAnimationDurationMs: Long

openingOvershootTension

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.

var openingOvershootTension: Float

orientation

The Orientation this FabOption is viewable in. Default value is Orientation.PORTRAIT.

var orientation: Orientation

Functions

setOnClickListener

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.

fun setOnClickListener(onClickListener: OnClickListener?): Unit

setSize

Sets the size of the FabOption. Overridden to ensure we never set the size to be FabSize.CUSTOM.

fun setSize(size: Int): Unit