Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Expandable Floating Action Button

Ryan Bishop Mayobre edited this page Jun 24, 2020 · 1 revision

Expandable Floating Action Button

This button extends the FAB view object. Works like a normal FAB, but has text extended to the right of the icon. It also has the option of collapsing into a normal FAB with no text.

Kotlin Functions

  • changeState(animate: Boolean = true) - Changes the state of the FAB from collapsed to expanded, vice versa. Can be done witout animation if false is passed in the parameters.
  • setText(text: String) - Set the text of the FAB.
  • setTextColor(color: Int) - Change the text color to color resource.
  • setTextColor(color: ColorStateList) - Change the text color to ColorStateList object.
  • setOnClickListener(listener: OnClickListener?) - Register a listener for click events.
  • setIcon(iconRes: Int): Boolean - Set a drawable resource as button icon. Returns true if successfully set an icon.
  • setIcon(iconDrawable: Drawable?): Boolean - Set a drawable object as the button's icon. Returns true if successfully set an icon.

XML Attributes

  • app:text - Set the text of the FAB.
  • app:textColor - Set the color of the text on the FAB.
  • app:elevation_height - Takes in a dimension and sets the elevation level to the button.
  • app:icon - Takes in a references and applies it to the center of button.