Organizational Research By

Surprising Reserch Topic

how can i add the new floating action button between two widgets layouts

how can i add the new floating action button between two widgets layouts  using -'android,floating-action-button'

I guess you have seen the new Android design guidelines, with the new "Floating Action Button" a.k.a "FAB"

For instance this pink button:

My question sounds stupid, and I have already tried a lot of things, but what is the best way to put this button at the intersection of two layouts?

In the above exemple, this button is perfectly placed between what we can imagine to be an ImageView and a relativeLayout.

I have already tried a lot of tweaks, but I am convinced there is a proper way to do it.

asked Sep 30, 2015 by sumit_jaiswalmca
0 votes

Related Hot Questions

9 Answers

0 votes

Best practice:

  • Add compile '' to gradle file
  • Use CoordinatorLayout as root view.
  • Add layout_anchorto the FAB and set it to the top view
  • Add layout_anchorGravity to the FAB and set it to: bottom|right|end

enter image description here"






answered Sep 30, 2015 by abhi
0 votes

Seems like the cleanest way in this example is to:

  • Use a RelativeLayout
  • Position the 2 adjacent views one below the other
  • Align the FAB to the parent right/end and add a right/end margin
  • Align the FAB to the bottom of the header view and add a negative margin, half the size of the FAB including shadow

Example adapted from shamanland implementation, use whatever FAB you wish. Assume FAB is 64dp high including shadow:"




FAB Layout example

answered Sep 30, 2015 by ajit.chavhan
0 votes

You can import the sample project of Google in Android Studio by clicking File > Import Sample...

Import sample

This Sample contains a FloatingActionButton View which inherits from FrameLayout.

Edit With the new Support Design Library you can implement it like in this example:

answered Sep 30, 2015 by dahiyabecomp
0 votes

Now it is part of official Design Support Library.

In your gradle:

compile ''

answered Sep 30, 2015 by virendra.bajaj
0 votes

Here is one aditional free Floating Action Button library for Android. It has many customizations and requires SDK version 9 and higher

enter image description here

Full Demo Video

dependencies {
    compile ''
answered Sep 30, 2015 by mca.agarwal
0 votes

With AppCompat 22, the FAB is supported for older devices.

Add the new support library in your build.gradle(app):

compile ''

Then you can use it in your xml:

To use elevation and pressedTranslationZ properties, namespace app is needed, so add this namespace to your layout: xmlns:app=""

answered Sep 30, 2015 by deepak07.s
0 votes

Try this library (javadoc is here), min API level is 7:

dependencies {
    compile 'com.shamanland:fab:0.0.8'

It provides single widget with ability to customize it via Theme, xml or java-code.

light between

It's very simple to use. There are available normal and mini implementation according to Promoted Actions pattern.

Try to compile the demo app. There is exhaustive example: light and dark themes, using with ListView, align between two Views.

answered Sep 30, 2015 by thiru
0 votes

Came across this post while i tried to implement it in my project floating button implementation what i like about it is it doesnt require use of third party libs.

answered Sep 30, 2015 by mannar kande
0 votes

Add this to your gradle file

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile ''

This to your activity_main.xml







You can find the full example with android studio project to download at

answered Sep 30, 2015 by patelnikul321