项目作者: islamdidarmd

项目描述 :
A small utility to show loading animation inside a button
高级语言: Kotlin
项目地址: git://github.com/islamdidarmd/LoadingButton.git
创建时间: 2018-11-22T09:31:15Z
项目社区:https://github.com/islamdidarmd/LoadingButton

开源协议:MIT License

下载


LoadingButton

A small utility to show loading animation inside a button

Codacy Badge

Installation (with Gradle)

Add the dependency to your root build.gradle:

  1. repositories {
  2. jcenter()
  3. maven { url "https://jitpack.io" }
  4. }

Now add this dependency in your module build.gradle

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

Demo

How to use

For using custom attributes use app namespace

  1. xmlns:app="http://schemas.android.com/apk/res-auto"
  1. <com.droidbond.loadingbutton.LoadingButton
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. app:text="Custom Button"
  5. app:background="@color/colorAccent"
  6. app:successBackground="@drawable/ic_bg_blue_buttons_style"
  7. app:successIcon="@drawable/ic_done_white_24dp"
  8. app:textSize="16sp"
  9. app:boldText="true"
  10. app:textColor="@color/black"
  11. app:progressColor="@color/black"
  12. app:progressBarSize="small"
  13. android:id="@+id/custombtn"
  14. app:layout_constraintStart_toStartOf="parent"
  15. android:layout_marginTop="20dp"
  16. app:layout_constraintTop_toBottomOf="@+id/normal"
  17. app:layout_constraintEnd_toEndOf="parent"
  18. android:layout_marginEnd="8dp"
  19. android:layout_marginRight="8dp"
  20. android:layout_marginStart="8dp"
  21. android:layout_marginLeft="8dp"></com.droidbond.loadingbutton.LoadingButton>

Customizable attributes

  1. <attr name="text" format="string"></attr>
  2. <attr name="textColor" format="color"></attr>
  3. <attr name="boldText" format="boolean"></attr>
  4. <attr name="textSize" format="dimension"></attr>
  5. <attr name="progressColor" format="color"></attr>
  6. <attr name="background" format="reference"></attr>
  7. <attr name="successBackground" format="reference"></attr>
  8. <attr name="errorBackground" format="reference"></attr>
  9. <attr name="successIcon" format="reference"></attr>
  10. <attr name="errorIcon" format="reference"></attr>
  11. <attr name="customFontFamily" format="reference"></attr>
  12. <attr name="progressBarSize" format="enum">
  13. <enum name="large" value="64"></enum>
  14. <enum name="medium" value="48"></enum>
  15. <enum name="small" value="18"></enum>
  16. </attr>
  1. LoadingButton custombtn = findViewById(R.id.custombtn);

Show Loading

  1. custombtn.showLoading()

Hide Loading

  1. custombtn.hideLoading()

Show Success

  1. custombtn.showSuccess()

Show Error

  1. custombtn.showError()

Loading status

  1. custombtn.isLoading()

Set Custom TypeFace

  1. custombtn.setTypeFace(typeface)

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