library / com.nambimobile.widgets.efab / ExpandableFabLayout

ExpandableFabLayout

class ExpandableFabLayout : 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:

<com.nambimobile.widgets.efab.ExpandableFabLayout android:layout_width="match_parent" android:layout_height="match_parent">

<com.nambimobile.widgets.efab.Overlay android:layout_width="match_parent" android:layout_height="match_parent"/>

<com.nambimobile.widgets.efab.ExpandableFab android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_marginBottom="@dimen/ui_margin_medium" android:layout_marginEnd="@dimen/ui_margin_medium" android:layout_marginRight="@dimen/ui_margin_medium"/>

<com.nambimobile.widgets.efab.FabOption android:layout_width="wrap_content" android:layout_height="wrap_content"/>

</com.nambimobile.widgets.efab.ExpandableFabLayout>

Developer Notes:

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

  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 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)

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.

ExpandableFabLayout(context: Context, attributeSet: AttributeSet)

Properties

landscapeConfiguration

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

var landscapeConfiguration: OrientationConfiguration

portraitConfiguration

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

var portraitConfiguration: OrientationConfiguration

Functions

addView

Adds a child view with the specified layout parameters to the ExpandableFabLayout.

fun addView(child: View?, index: Int, params: LayoutParams?): Unit

addViews

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.

fun addViews(vararg children: View?): 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.

fun close(): Unit

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.

fun getCurrentConfiguration(): OrientationConfiguration

isOpen

Returns true if the ExpandableFab is currently open (any attached Overlay, FabOption and Labels are visible and all animations are done).

fun isOpen(): Boolean

removeAllViews

Removes all child views in both portrait and landscape orientation from the ExpandableFabLayout.

fun removeAllViews(): Unit