android 固定进度无限旋转的环形效果
效果图
Activity 中使用
val rotation: ObjectAnimator = ObjectAnimator. ofFloat ( progressBar, "rotation" , 0f , 360f )
rotation. duration = ·000
rotation. repeatCount = ObjectAnimator. INFINITE
rotation. interpolator = LinearInterpolator ( )
rotation. start ( )
布局样式
< ProgressBar
android: id= "@+id/progressBar"
android: background= "@drawable/pb_circular_bg"
android: progressDrawable= "@drawable/pd_circular_progress"
android: indeterminateOnly= "false"
android: indeterminate= "false"
android: layout_width= "50dp"
android: layout_height= "50dp"
android: max= "100"
android: progress= "25" / >
背景样式 pb_circula_bg.xml
< ? xml version= "1.0" encoding= "utf-8" ? >
< shape xmlns: android= "http://schemas.android.com/apk/res/android"
android: innerRadiusRatio= "3"
android: shape= "ring"
android: thicknessRatio= "8"
android: useLevel= "false" >
< solid android: color= "@color/theme_c_d9" / >
< / shape>
进度样式 pd_circular_progress.xml
< ? xml version= "1.0" encoding= "utf-8" ? >
< shape xmlns: android= "http://schemas.android.com/apk/res/android"
android: innerRadiusRatio= "3"
android: shape= "ring"
android: thicknessRatio= "8"
android: useLevel= "true" >
< solid android: color= "@color/colorPrimary" / >
< / shape>