20

I need to implement a floating action button, according to Google Design Guidelines, on my android application with API level 19.

However, I would know if some native support library (like v4, v7, v13) to help me build this component without the need for external dependencies.

falvojr
  • 3,060
  • 4
  • 31
  • 54
  • 1
    https://github.com/shamanland/floating-action-button i think that works out ok on API 19 double check gradle.build for the dependency – Robert Rowntree Nov 14 '14 at 21:52

2 Answers2

22

I would know if some native support library (like v4, v7, v13) to help me build this component without the need for external dependencies.

No there aren't any support library floating action buttons (FAB). IMHO, it's a horrible decision to not include all of the material related widgets in the support library. In this video Chet Haase and Adam Powell basically say that the FAB is very easy to reproduce so they're not going to include it in any support library. So instead of Google creating one set of the material widgets to be used by millions of developers they would rather millions of developers create millions of different implementation of these widgets. </rant>

You can just make your own FAB by extending the View class. Here is an example from Github of a FAB that does not use any outside libraries.

MrEngineer13
  • 38,642
  • 13
  • 74
  • 93
  • 4
    Thanks @MrEngineer13! This was one of the most enlightening answers I've ever had! It's a little frustrating the Google has not evolve the SDK before releasing its new design guideline. But it is a reasonable strategy if we consider the great community activity. – falvojr Nov 14 '14 at 22:36
  • 1
    I believe Google will ad it eventually, just like Support ActionBar. P.S: you forgot the open the rant tag :P – Sufian Apr 21 '15 at 07:44
  • 1
    https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html – Max Jun 23 '15 at 11:21
14

Recently Google has released a new support library based on Material Design Guideline. The Codepath details the same components in this post.

The library can be already used with Gradle adding the following line in build.gradle:

dependencies {
    ...
    compile 'com.android.support:design:25.3.1'
}

This is a simple example of usage:

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

See more FloatingActionButton example with Support Library.

Community
  • 1
  • 1
falvojr
  • 3,060
  • 4
  • 31
  • 54