Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
/ LoadingButton Public archive

A small utility to show loading animation inside a button

License

Notifications You must be signed in to change notification settings

islamdidarmd/LoadingButton

Repository files navigation

LoadingButton

A small utility to show loading animation inside a button

Codacy Badge

Installation (with Gradle)

Add the dependency to your root build.gradle:

   repositories {
        jcenter()
        maven { url "https://jitpack.io" }
   }

Now add this dependency in your module build.gradle

   dependencies {
         implementation 'com.github.islamdidarmd:LoadingButton:0.1.8'
   }

Demo

How to use

For using custom attributes use app namespace

xmlns:app="http://schemas.android.com/apk/res-auto"
     <com.droidbond.loadingbutton.LoadingButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:text="Custom Button"
                app:background="@color/colorAccent"
                app:successBackground="@drawable/ic_bg_blue_buttons_style"
                app:successIcon="@drawable/ic_done_white_24dp"
                app:textSize="16sp"
                app:boldText="true"
                app:textColor="@color/black"
                app:progressColor="@color/black"
                app:progressBarSize="small"
                android:id="@+id/custombtn"
                app:layout_constraintStart_toStartOf="parent"
                android:layout_marginTop="20dp"
                app:layout_constraintTop_toBottomOf="@+id/normal"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginLeft="8dp"/>

Customizable attributes

         <attr name="text" format="string"/>
                <attr name="textColor" format="color"/>
                <attr name="boldText" format="boolean"/>
                <attr name="textSize" format="dimension"/>
                <attr name="progressColor" format="color"/>
                <attr name="background" format="reference"/>
                <attr name="successBackground" format="reference"/>
                <attr name="errorBackground" format="reference"/>
                <attr name="successIcon" format="reference"/>
                <attr name="errorIcon" format="reference"/>
                <attr name="customFontFamily" format="reference"/>
                <attr name="progressBarSize" format="enum">
                    <enum name="large" value="64"/>
                    <enum name="medium" value="48"/>
                    <enum name="small" value="18"/>
                </attr>
LoadingButton custombtn = findViewById(R.id.custombtn);

Show Loading

custombtn.showLoading()

Hide Loading

custombtn.hideLoading()

Show Success

custombtn.showSuccess()

Show Error

custombtn.showError()

Loading status

custombtn.isLoading()

Set Custom TypeFace

custombtn.setTypeFace(typeface)

For a complete example, see the sample app https://github.com/droidbond/LoadingButton/tree/master/app