项目作者: StevenDXC

项目描述 :
Android material button with loading animation
高级语言: Kotlin
项目地址: git://github.com/StevenDXC/DxLoadingButton.git
创建时间: 2016-10-13T05:55:22Z
项目社区:https://github.com/StevenDXC/DxLoadingButton

开源协议:Apache License 2.0

下载


DxLoadingButton

android button to loading view with animation,and load successful/failed animation


API
Codacy Badge

Demo:

image

with activity transition animation demo:

image

Usage:

layout:

  1. <com.dx.dxloadingbutton.lib.LoadingButton
  2. android:id="@+id/loading_btn"
  3. android:layout_gravity="center"
  4. android:layout_width="228dp"
  5. android:layout_height="wrap_content"
  6. app:lb_resetAfterFailed="true"
  7. app:lb_btnRippleColor="#000000"
  8. app:lb_btnDisabledColor="#cccccc"
  9. app:lb_disabledTextColor="#999999"
  10. app:lb_cornerRadius="32"
  11. app:lb_rippleEnable="true"
  12. app:lb_btnText="@string/button_text"
  13. ></com.dx.dxloadingbutton.lib.LoadingButton>

code:

  1. LoadingButton lb = (LoadingButton)findViewById(R.id.loading_btn);
  2. lb.setOnClickListener(new View.OnClickListener() {
  3. @Override
  4. public void onClick(View view) {
  5. lb.startLoading(); //start loading
  6. }
  7. });

show successful animation:

  1. lb.loadingSuccessful();

show failed animation:

  1. lb.loadingFailed();

cancel loading:

  1. lb.cancelLoading();

reset:

  1. lb.reset();

enable:

  1. lb.setEnable(true/false);
  • notice: lb_btnDisabledColor & lb_disabledTextColor only display while LoadingButton is normal button state, LoadingButton is playing animation or other state will display normal color

image

backgroundShader:

  1. lb.setBackgroundShader(new LinearGradient(0f,0f,1000f,100f, 0xAAE53935, 0xAAFF5722, Shader.TileMode.CLAMP));

cornerRadius:

  1. lb.setCornerRadius(32f)

dependency

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:

  1. dependencies {
  2. compile 'com.github.StevenDXC:DxLoadingButton:2.4'
  3. }