Awesome
FloatingActionButton
A port of Faiz Malkani's FloatingActionButton backport, which backports the Floating Action Button from Android L to API 15 and up.
Drawables contained in the FAB are 24dp, and this is the preferred size.
Instructions
-
Use a
FrameLayout
to layer your layouts, and place the FAB in the bottom to make it appear on top:<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Your layouts here. Do not put anything below the FAB layout, unless you want it to overlap it. --> <dk.ostebaronen.floatingactionbutton.Fab android:id="@+id/fabbutton" android:layout_width="72dp" android:layout_height="72dp" android:layout_gravity="bottom|right" android:layout_marginBottom="16dp" android:layout_marginRight="16dp" /> </FrameLayout>
-
Initialize FAB in your Activity's
OnCreate()
method:var fab = FindViewById<Fab>(Resource.Id.fabbutton);
-
Use the
FabColor
andFabDrawable
methods to change the color and image inside of it:fab.FabColor = Color.Blue; fab.FabDrawable = Resources.GetDrawable(Resource.Drawable.ic_my_fab);
-
Use
Hide()
andShow()
to hide and show the FAB. Use theAlpha
property to set the transparency. Assign theClick
event to handle user clicks on the FAB.
License
This derivative work is licensed under The MIT License (MIT).