LoadingButton in Android
In this article, LoadingButton is added in android. LoadingButton provides us an amazing UI and an animation whenever the user taps on it. It is very easy to add a LoadingButton in an app. It is very much similar to Button in android, just add the dependency and a few properties. Tags like BL_backgroundColor, BL_circleColor, BL_circleColorSecond, BL_stateShow and many more can be used to customize the Loading Button. Loading Button View is used wherever the developer wants the user to wait for some time. We can also use Progress Bar instead of this but Loading Button provides unique and attractive UI and increases the user experience. It also provides full control to Developer as it can be customized according to the requirements.
Approach:
Step 1: Add the support Library in your root build.gradle file (not your module build.gradle file). This library jitpack is a novel package repository. It is made for JVM so that any library which is present in github and bitbucket can be directly used in the application.
XML
Step 2: Add the support Library in build.gradle file and add dependency in the dependencies section.
XML
dependencies { //For Snackbar implementation 'com.google.android.material:material:1.1.0' //For LoadingButton implementation 'com.github.andreasagap:LoadingButtonLibrary:v1.0' } |
Step 3: Add the following code in activity_main.xml file. In this file we add our LoadingButton to the layout.
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/root"
android:layout_height="match_parent">
<andreasagap.loadingbutton.ButtonLoading
android:id="@+id/loadingbutton"
android:layout_width="200dp"
android:layout_height="50dp"
android:padding="6dp"
app:BL_backgroundColor="#9c9b9999"
app:BL_circleColor="#219806"
app:BL_circleColorSecond="#126300"
app:BL_enable="true"
app:BL_stateShow="normal"
app:BL_text="Buy Course"
app:BL_textColor="#FFF"
app:BL_textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Please Login to comment...