项目作者: andreasagap

项目描述 :
A loading button with animaton
高级语言: Java
项目地址: git://github.com/andreasagap/LoadingButtonLibrary.git
创建时间: 2018-11-18T10:14:45Z
项目社区:https://github.com/andreasagap/LoadingButtonLibrary

开源协议:

下载


LoadingButton


License
Build Status
Android Arsenal



Demo

Usage

Step 1

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add dependency in your app level build.gradle.

  1. dependencies {
  2. implementation 'com.github.andreasagap:LoadingButtonLibrary:v1.0'
  3. }

Step 2

In xml

  1. <android.support.constraint.ConstraintLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:id="@+id/root"
  7. android:layout_height="match_parent">
  8. <andreasagap.loadingbutton.ButtonLoading
  9. android:id="@+id/loadingbutton"
  10. android:layout_width="match_parent"
  11. android:layout_height="48dp"
  12. app:BL_backgroundColor="#9c9b9999"
  13. app:BL_backgroundDisableColor="#00AFEF"
  14. app:BL_circleColor="#00AFEF"
  15. app:BL_circleColorSecond="#8000AFEF"
  16. app:BL_enable="true"
  17. app:BL_stateShow="normal"
  18. app:BL_text="Login"
  19. app:BL_textColor="#ffffff"
  20. app:BL_textDisableColor="#000000"
  21. app:BL_textSize="16sp"></andreasagap.loadingbutton.ButtonLoading>
  22. </android.support.constraint.ConstraintLayout>

In activity or fragment

  1. ConstraintLayout root=findViewById(R.id.root);
  2. ButtonLoading buttonLoading=findViewById(R.id.loadingbutton);
  3. buttonLoading.setRoot(buttonLoading,this,root);
  4. buttonLoading.setOnButtonLoadingListener(new ButtonLoading.OnButtonLoadingListener() {
  5. @Override
  6. public void onClick() {
  7. //...
  8. }
  9. @Override
  10. public void onStart() {
  11. //...
  12. }
  13. @Override
  14. public void onFinish() {
  15. //...
  16. }
  17. });

End Progress

Just call buttonLoading.cancel(); and the button moves to its original position.


:exclamation: Without cancel(), the function onFinish() doesn’t start.

Configure XML

  • BL_backgroundColor
  • BL_backgroundDisableColor
  • BL_circleColor color
  • BL_circleColorSecond
  • BL_stateShow: normal,animationStart,progress,animationFinish | default value is normal
  • BL_text: text button
  • BL_textColor
  • BL_textDisableColor
  • BL_textSize
  • BL_enable
  • BL_font: address font in assets. example: file in assetst > fonts > arial.ttf ==> fonts/arial.ttf

Credits

This library was based on this repo: https://github.com/rasoulmiri/ButtonLoading :clap: