java – Android Floating Action Button API 19 (KitKat)-ThrowExceptions

Exception or error:

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.

How to solve:

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.

###

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.

Leave a Reply

Your email address will not be published. Required fields are marked *