1.先導入函示庫(build.gradle: Module)
dependencies {
implementation 'com.dinuscxj:circleprogressbar:1.3.6'
}
2.程式碼範例
a.Layout
<com.dinuscxj.progressbar.CircleProgressBar
android:id="@+id/circle_bar"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
b.設置動畫
val animator = ValueAnimator.ofInt(0, 101)
animator.addUpdateListener {
val progress = it.animatedValue as Int
circle_bar.progress = progress
}
animator.repeatCount = ValueAnimator.INFINITE
animator.duration = 4000
animator.start()
3.效果展示