Skip to content Skip to sidebar Skip to footer

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. There are many library offering this component on GitHub as: Android-floati

Solution 1:

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:

FloatingActionButtonfab= (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(newView.OnClickListener() {
    @OverridepublicvoidonClick(View view) {
        //TODO
    }
});

Solution 2:

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

Solution 3:

You can use the class md-fab on a md-button then add a span with something like a plus sign inside of the md-button. Also there are other md-fab classes like md-fab-bottom-right which might help you out. Also you can use an md-icon inside your md-button

<md-buttonclass="md-fab"><spanclass="glyphicon glyphicon-plus" /></md-button>

Solution 4:

All the above answers are now out of date.

FABS are available as part of Material Components for Android: https://material.io/develop/android/docs/getting-started/

Here is the class: https://developer.android.com/reference/com/google/android/material/floatingactionbutton/FloatingActionButton

Don't miss the Catalog app with working examples: https://github.com/material-components/material-components-android

Post a Comment for "Is There A Native Component For The Floating Action Button In Android Material Design?"