Floating Action Button Example in Android 5.0

Android announced Material Design as a new feature to Android 5.0 Lollipop version. Material Design guides creation of user experiences that work well on different devices, with different input methods and on different platforms. Google is gradually implementing Material Design in their apps and products.

One interesting new design pattern is the promoted action, implemented as a floating action button. This pattern describes the underlying principles of Material Design and is a good place to start adapting existing applications to the new version of Android. In this example we will see how to implement a floating action button.

You will need android studio or Android L preview setup installed on your system to check this example running.

Example Steps

1.) Create a new project and name it FloatingActionButton.
2.) Write following into main.xml:




3.) Create and write following into fab_layout.xml:




4.) Write following into mainActivity: