[Android] How to build an Android Floating Action Button Menu
Hi,
I’m a FullStack Developer (J2EE, JS, SQL), I know Java but not explicitly Android Development guidelines.
So I currently joining the open-source team of NewPipe : A free lightweight Youtube frontend for Android to improve my skills.
During the development of PlayList support on NewPipe a question came to mind :
How to make a correct menu in material design under android ?
I have needing using a new material menu provide by Floating Action Button (like Inbox, Hangout, …) for minSdkVersion=14
How to proceed ?
After some search on internet, I found these stackoverflow thread and it’s list four libs for made the job:
|
|
But in the comment one person used Android Floating Action Button (futuresimple) in production to more than 100K users and he never had any issues for the lib, so I choice the same of him.
Adding in the code
Edit the .gradle
You just need to add the Android Floating Action Button lib on your gradle file
|
|
Add on XML files
1. Drawable file
fab_label_background.xml
|
|
2. Values’s files
colors.xml
|
|
styles.xml
|
|
2. Layout’s files
floating_menu.xml
|
|
Don’t forgive to add on your parent layout the xml inclusion of the new layout :
|
|
Add on Java Activity part
Add the following import
|
|
Add create the method for init the FloatingActionButton menu (call inside your init view)
|
|
And it’s work :)
PS: If you needing an Android support with minSdkVersion=4
check here.
References
- android-design-support-library-fab-menu
- floating-action-button-and-white-background
- android-floating-action-button