Search This Blog

July 15, 2015

Adding Floating Action Button to Android Application

Floating Action Button (FAB) is simply a circle button with some drop shadow that unbelieveably could change the world of design. No surprise why it becomes a signature of Material Design. So let's start with this thing. Add FAB in layout file with FloatingActionButton and wrap it with FrameLayout since it needs some parent to make it aligned at bottom right position of the screen.

Adding Floating Action Button to Android Application

First thing to do to include Android Design Support Library in our project is to add a line of dependency code in app's build.gradle file.

compile ''



            app:fabSize="normal" />


android:src is used to define a Resource ID of icon you want (40dp transparent png file is recommended) while app:fabSize="normal" is used to define FAB's size. normal means the standard 56dp button used in most of the case but in case you want to use the smaller one, mini is an another choice that will change its width to 40dp.

 Add the following line of codes in your java Activity file.

FloatingActionButton fabBtn;

 fabBtn = (FloatingActionButton) findViewById(;
    fabBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {



1 comment:

Earn Money From Home