Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Floating Action Button API 19 (KitKat)

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.

like image 779
falvojr Avatar asked Nov 14 '14 11:11

falvojr


People also ask

How do you use a floating action button?

Add the floating action button to your layoutThe size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.


2 Answers

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.

like image 193
MrEngineer13 Avatar answered Sep 22 '22 13:09

MrEngineer13


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.

like image 22
falvojr Avatar answered Sep 23 '22 13:09

falvojr