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.
You can import the sample project of Google in Android Studio by clicking File > 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: https://github.com/chrisbanes/cheesesquare
With AppCompat 22, the FAB is supported for older devices.
Add the new support library in your build.gradle(app):
Then you can use it in your xml:
To use
elevation
andpressedTranslationZ
properties, namespaceapp
is needed, so add this namespace to your layout:xmlns:app="http://schemas.android.com/apk/res-auto"
Keep it Simple Adding Floating Action Button using TextView by giving rounded xml background. - Add compile
com.android.support:design:23.1.1
to gradle fileCircle Xml is
Layout xml is
Click here to se how it Will look like
Best practice:
compile 'com.android.support:design:25.0.1'
to gradle fileCoordinatorLayout
as root view.layout_anchor
to the FAB and set it to the top viewlayout_anchorGravity
to the FAB and set it to:bottom|right|end
Here is one aditional free Floating Action Button library for Android. It has many customizations and requires SDK version 9 and higher
Full Demo Video
Add this to your gradle file
This to your activity_main.xml
You can find the full example with android studio project to download at http://www.ahotbrew.com/android-floating-action-button/