Android Floating Action Button Speed Dial

Android Floating Action Button Speed Dial

Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Features

  • MinSdk 14
  • Highly customizable (label, icon, ripple, fab and label background colors, themes support)
  • Same animations as in Inbox by Gmail
  • Option to have different icons for open/close state
  • Optional overlay/touch guard layout
  • Support for bottom, left and right menu expansion (left and right have no labels)
  • Out-of-the box support for Snackbar behavior
  • Optional support for RecyclerView and NestedScrollView behavior
  • Support for VectorDrawable
  • Easy to use

Development status

Check the Waffle.io board.

How to use

Gradle setup

Official releases

The library is available on Jcenter so no additonal repository is required.

Dependencies entry (latest version on Jcenter ):

Snapshots (development branch)

You can use JitPack to test the latest master (remember that master is the development branch and can be unstable or completely broken).

Add the JitPack repository to your build file:

Add the dependency

Basic use

SpeedDialView

Add the SpeedDialView to your layout:

Action items

Add the items to the SpeedDialView:

If the color customization is not requested, it is also possible to inflate the Action items form a Menu Resource:

Only the attributes android:idandroid:icon and android:title are supported.

Click listeners

Add the click listeners:

Optional steps

Add the main action click listener

Customizing the items

The SpeedDialActionItem.Builder provides several setters to customize the aspect of one item:

Is is also possible to specify a theme to easily change the FAB background and ripple effect color:

Adding an overlay/touch guard when the menu is open (like Inbox by Gmail)

You simply need to add the SpeedDialOverlayLayout to your layout:

and then provide the instance of that layout to the SpeedDialView:

or

Hiding the FAB when scrolling a RecyclerView or a NestedScrollView

Just apply the ScrollingViewSnackbarBehavior to the SpeedDialView. This can be done via XML using the convenience string resource @string/speeddial_scrolling_view_snackbar_behavior:

Or programmatically:

NB: for the behaviors to work, SpeedDialView needs to be a direct child of CoordinatorLayout

Disabling SnackbarBehavior

Since the SnackbarBehavior is enabled by default and, afaik, it is not possible to remove a Behavior, simply use apply the SpeedDialView.NoBehavior instead:

Sample project

A fully working example is available here.

Demo

Video

Sample app

Screenshots

API 27, API 16, bottom and left expansion

FAQ

How can I create a new resource ID, required by the SpeedDialActionItem.Builder?

It can be done in XML using the <item type="id" />:

How can I change the maximum length of the label?

You can set a different value for the max length of the label overriding sd_label_max_width:

More info here.

How can I change the color of the overlay / touch guard layout?

The color of the SpeedDialOverlayLayout can be changed simply using the android:background attribute or, programmatically, using the equivalent setter like any other view.

How can I prevent the overlay / touch guard layout from going over the Toolbar inside a CoordinatorLayout?

It can be done using the attribute app:layout_behavior="@string/appbar_scrolling_view_behavior":

Changelog

See the CHANGELOG.md

Credits

This project is based on floating-action-menu by ArthurGhazaryan.

182 total views, 3 views today

(Visited 75 times, 1 visits today)

You May Also Like

About the Author: Android Developer

This is Mohammad I am Android Application Developer. I am the founder of Android Tutorial Online blog. I am programming lover and professional blogger from India. I spend most of my time doing programming and helping other programmers. This Android tutorial online blog for learning and share Android code.
My Chatbot
Powered by Replace Me