Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a native component for the Floating action button in Android Material Design?

My question revolves around the Floating action button that was introduced in Android Material Design.

enter image description here

There are many library offering this component on GitHub as:

  1. Android-floating-action-button
  2. FloatingActionButton
  3. CircularFloatingActionMenu
  4. Fab
  5. Floating-action-button

But my question is:

Is there a native component with the last release of android.support.vX that was built for Floating action button?

Components such as :

  • android.support.v7.cardview
  • android.support.v4.widget.DrawerLayout
  • android.support.v7.widget.RecyclerView
  • ...
like image 597
lopez.mikhael Avatar asked May 27 '15 12:05

lopez.mikhael


2 Answers

Today (29/05/2015) it is officially avaiable with the new Material Design support Library.

Just add this dependency to your build.gradle

compile 'com.android.support:design:22.2.0'

Add this view to your layout:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:src="@drawable/ic_done" />

And use it:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        //TODO
    }
});
like image 91
Gabriele Mariotti Avatar answered Sep 30 '22 15:09

Gabriele Mariotti


Not yet, there have been hints that we will see it in the next support lib.

like image 37
Mark Hetherington Avatar answered Sep 30 '22 15:09

Mark Hetherington