15

enter image description here

There are lots of custom libraries for achieving the FAB menu thing. But I want it to be done without using any custom libraries. I want to achieve this FAB Menu natively.

Please don't suggest me any custom library

2
  • 1
    Currently this feature is not supported by official FAB. You'll have to implement it yourself or use some library.
    – Mangesh
    Nov 8, 2015 at 4:33
  • What libraries may produce this type of FAB? Jan 29, 2019 at 7:05

3 Answers 3

3

You can go for android's design library. add this gradle in to your build file

compile 'com.android.support:design:23.0.1'

and follow this link, which is a stackoverflow link tells how to use. and this is the link of an sample app.

Example :

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    android:clickable="true"
    android:src="@drawable/ic_done"
    app:layout_anchor="@id/viewA"
    app:layout_anchorGravity="bottom|right|end"/>

you can create multiple fab and play with its visibility

UPDATE

I think you have to use third party library to do this. please go through this library, this might help you

4
  • 7
    This does not answer the question.
    – Mangesh
    Nov 3, 2015 at 7:20
  • 1
    @MangeshGhotage what do you suggest then ?
    – droidev
    Oct 8, 2016 at 18:41
  • the support library is hardly a "custom" library. it is an extension created to avoid bloating the core app, unless necessary.
    – tony gil
    Nov 10, 2016 at 11:55
  • 1
    @tonygil but I think OP refers custom library to third party library.
    – droidev
    Nov 13, 2016 at 14:48
0

add this dependency to the app build.gradle

compile 'com.android.support:design:23.1.0' 
 compile 'com.github.clans:fab:1.6.2'

Add follow the below link Floating Action Menu

1
  • the library has been discontinued for a while now
    – Alberto M
    Mar 26, 2020 at 8:14
0

You could do this natively using visibility... Each press on the FAB (ImageView) will toggle visibility with an animation.

I won't write a working sample code, but this should be enough info to help implement a custom floating action button in this way.

XML

android:onClick="fabMainClicked"    

JAVA

public void fabMainClicked(View view) 
{
    ImageView fabDrop1 = (ImageView) findViewById(R.id.fabDrop1);
    ImageView fabDrop2 = (ImageView) findViewById(R.id.fabDrop2);
    if (fabDrop1.getVisibility() == fabDrop1.GONE)
    {
        fabDrop1.setVisibility(fabDrop1.VISIBLE);
        fabDrop2.setVisibility(fabDrop2.VISIBLE);
    }
}  

Each ImageView will need to be animated via a custom animator to slide up or onto the screen.

Each ImageView will use a res/drawable as the background to provide a circle and a res/drawable for the center image.

Scale type should be set to center.

Good luck.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.