A loading view that includes two rotating arcs(一个包含两条圆弧互相旋转的loading view).
在根目录的build.gradle添加这一句代码:
allprojects {
repositories {
//...
maven { url 'https://jitpack.io' }
}
}
在app目录下的build.gradle添加依赖使用:
dependencies {
implementation 'com.github.samlss:WhirlLoadingView:1.0'
}
布局中使用:
<com.iigo.library.WhirlLoadingView
android:id="@+id/wlv_loading"
android:layout_centerInParent="true"
android:layout_width="60dp"
app:duration="900"
app:loadingColor="@android:color/white"
app:interpolator="LinearInterpolator"
android:layout_height="60dp" />
代码中使用:
whirlLoadingView.pause(); //暂停动画
whirlLoadingView.resume(); //恢复动画
whirlLoadingView.start(); //开始动画
whirlLoadingView.stop(); //停止动画
whirlLoadingView.release(); //不需要使用该loading view的时候可手动释放,例如在activity的ondestroy()中
whirlLoadingView.setColor(Color.RED); //圆弧颜色
属性说明:
属性 | 说明 |
---|---|
loadingColor | 旋转圆弧的颜色 |
duration | 动画时间 |
interpolator | 动画加速器 |
- AccelerateDecelerateInterpolator
- AccelerateInterpolator
- DecelerateInterpolator
- BounceInterpolator
- CycleInterpolator
- LinearInterpolator
- AnticipateOvershootInterpolator
- AnticipateInterpolator
- OvershootInterpolator
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
//...
maven { url 'https://jitpack.io' }
}
}
Add it in your app build.gradle at the end of repositories:
dependencies {
implementation 'com.github.samlss:WhirlLoadingView:1.0'
}
in layout.xml:
<com.iigo.library.WhirlLoadingView
android:id="@+id/wlv_loading"
android:layout_centerInParent="true"
android:layout_width="60dp"
app:duration="900"
app:loadingColor="@android:color/white"
app:interpolator="LinearInterpolator"
android:layout_height="60dp" />
in java code:
whirlLoadingView.pause(); //pause animation
whirlLoadingView.resume(); //resume animation
whirlLoadingView.start(); //start animation
whirlLoadingView.stop(); //stop animation
whirlLoadingView.release(); //Can 'released' when you don't need to use the loading view, for example in the activity's onDestroy()
whirlLoadingView.setColor(Color.RED); //set the color of the arcs
Attributes description:
attr | description |
---|---|
loadingColor | the color of the rotating arcs |
duration | the animation duration |
interpolator | the animation interpolator |
- AccelerateDecelerateInterpolator
- AccelerateInterpolator
- DecelerateInterpolator
- BounceInterpolator
- CycleInterpolator
- LinearInterpolator
- AnticipateOvershootInterpolator
- AnticipateInterpolator
- OvershootInterpolator