I am a beginner at Android Studio and using the following library https://github.com/futuresimple/android-floating-action-button to add Floating Action Button into my project but I don't know how to do that. Please guide me.
Updated for AndroidX:
You can use Google's native implementation of FAB: com.google.android.material.floatingactionbutton.FloatingActionButton
Dependency: com.google.android.material:material:1.0.0
Previously (before AndroidX):
I would suggest using the Design Support Floating Action Button supplied by Google instead as seen here http://android-developers.blogspot.com/2015/05/android-design-support-library.html add this to your gradle:
dependencies {
compile 'com.android.support:design:23.0.0'
}
and that will include the FloatingActionButton shown here: http://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html?utm_campaign=io15&utm_source=dac&utm_medium=blog
It is generally a better practice to use a supported library than a 3rd party one.
I'm a little bit late, but for those who will be looking on how to add Floating Action Button to project that requires changes in project due to recent migrations to androidx here is the answer. Instead of
com.android.support:design
use new com.google.android.material:material:1.0.0-rc01
:
dependencies {
implementation 'com.google.android.material:material:1.0.0-rc01'
}
After syncing project just declare FAB in your activity xml file:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:layout_marginEnd="24dp"/>
Just add the dependency to your build.gradle:
dependencies {
compile 'com.getbase:floatingactionbutton:1.9.0'
}
To see how the buttons are added to your xml layouts, check the sample project.
There are two ways you can use library:
build.gradle
file. Example: com.getbase:floatingactionbutton:1.9.0, com.android.support:appcompat-v7:21.0.3If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With