How to add the FAB to the layout

suggest change

To use a FloatingActionButton just add the dependency in the build.gradle file as described in the remarks section.

Then add to the layout:

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

An example:

Color

The background color of this view defaults to your theme’s colorAccent.

If src is only the plus icon (24x24 dp by default), set the circle color with app:backgroundTint="@color/your_colour".

To change that color in code, color is an ARGB int:

myFab.setBackgroundTintList(ColorStateList.valueOf(color));

To change the pressed-state color:

mFab.setRippleColor(color);

Positioning

Place the button at least 16 dp from the edge on a phone, and at least 24 dp on a tablet or desktop.

Note: When src is meant to cover the whole FloatingActionButton, use an image of that size.

Default circle size is 56 x 56dp

Mini circle size : 40 x 40dp

To change only the interior icon, use a 24 x 24 dp icon for the default size.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents