Include Floating Action Button library - android

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.
For knowledge:
There are two ways you can use library:
First way, if the library owner has published library on maven central or any other repository, then we just need to use the given artifact ID in build.gradle file. Example: com.getbase:floatingactionbutton:1.9.0, com.android.support:appcompat-v7:21.0.3
Another way is to refer the library project in your project, same as what we were doing in Eclipse.

Related

adding com.android.support:design:28.0.0 dependency

I am trying to add Floating Edit text to my app. For this have added 'com.android.support:design:28.0.0' dependency to my build.gradle (;app).
I'm getting this following error if try to run the project.
if need to refactor>Migrate to androidX :(please guide me to the process)
You don't need this dependency since you are using the Material components library (it is a drop-in replacement for Android's Design Support Library).
Just remove it.

implementing card view in build.gradle

I am trying to implement card view by implementing it in my build.gradle.
However while doing this, I am getting an error. It is saying
"Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX... less... (Ctrl+F1)"
I understand how to do it but am not sure if I should since I am not getting any build errors and my gradle is still syncing. Can someone tell me whats going on?
You are using androidx libraries together with a very old version of support library of cardview.
Remove the dependency of support library
//implementation 'com.android.support:cardview-v7:16.0.4'
and add:
implementation 'androidx.cardview:cardview:1.0.0'
More info about androidx here.
You have another option.
Just add the MaterialCard included in the official Material Components library:
implementation 'com.google.android.material:material:1.1.0-alpha10'
and in your xml you can use:
<com.google.android.material.card.MaterialCardView
...>
Just open your project and make the compile and target version to 28 , then sync then go to refractor on toolbar of studio , there you will see migrate to android x just tap on that. It will resolved all your issue.

dependency "androidx.core:core-ui" not found

When adding constraint layout group to my project, Android studio auto add the dependency in gradle:
implementation 'androidx.core:core-ui:+'
But I've got this error message:
Failed to resolve: androidx.core:core-ui:+
I couldn't find any way to add corresponding androidx dependency, the only solution I know so far is using support lib but It against the guideline to move everything to androidx.
com.android.support:support-core-ui:28.0.0
Is there any androix dependency which includes the ConstraintLayout Group?
Use this in your app gradle file instead...
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0-alpha1'
Try adding this to your build.gradle file implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
constraint layout does not show up for me to drag it into the layout editor(3.2 canary) but I can use it by writing the code in xml and adding this library. For any other dependencies, try writing the specific dependency in gradle, it appears core-ui for androidx not working yet.
Edit:
There should be a download icon next to the dependencies you don't have. You can click on it and there will be a pop up stating the dependency name. In Studio 3.2 Canary on windows, it is not adding these dependencies automatically, which is why my solution is to implement the dependency in build.gradle manually.

material support library, can't find Cardview/Recycleview

I have searched the internet but i couldn't find my answer. How can I use Card view/Recycle view they are not in my layout palette or i can't use them manually and I am using eclipse
The CardView and RecycleView are not by default in the AppCompat library. You should include the CardView and RecycleView libraries manual to your project.
Reference: https://developer.android.com/training/material/lists-cards.html#Dependencies
Gradle (using Android Studio):
dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
}
In the layout palette there is a section called "Custom" click on the "CustomView" and you shall see all the imported views from the dependencies added in the gradle file.
my problem when adding the library was the same as this guys problem
Unable to add library to android project
so I fixed it.

Including android.support.v7.app dependency in Android Studio

I'm migrating from Eclipse over to Android Studio and am looking at the Navigation Drawer example from Google. Right away, I see that I get this warning;
It looks like I need to use the v7 library rather than the v4. I can't figure out how to do this. In Eclipse, I just added a dependency from the build tools, but I see no such option in Android Studio. If I look at the build.gradle file, I can see this:
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
I just downloaded Android Studio yesterday, so I think that I should have this dependency somewhere, but I just don't know how to include it. Can someone tell me how to do this?
From within Android Studio, you can go to File, Project Structure, select your module, and go to the Dependencies tab - you'll see a list of dependencies - you can add new dependencies via the + sign near the bottom of that screen - it will automatically suggest the most popular libraries and all Google libraries including the one you want: appcompat-v7. This controls the build.gradle file and, in your case, adds the line:
compile 'com.android.support:appcompat-v7:21.0.3'
Note that you can also use sites such as Gradle, please to manually figure out what the dependency should be and add it to your build.gradle file yourself if you'd like.

Categories

Resources