A small utility to show loading animation inside a button
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'
}
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"/>
<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);
custombtn.showLoading()
custombtn.hideLoading()
custombtn.showSuccess()
custombtn.showError()
custombtn.isLoading()
custombtn.setTypeFace(typeface)
For a complete example, see the sample app https://github.com/droidbond/LoadingButton/tree/master/app