Compose 里实现 LoadingCircularProgress
@Composable
fun LoadingAnimation(
indicatorSize: Dp = 108.dp,
circleColors: List<Color> = listOf(
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_thumb),
colorResource(id = R.color.progress_thumb),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
colorResource(id = R.color.progress_track),
),
animationDuration: Int = 360
) {
val infiniteTransition = rememberInfiniteTransition(label = "loading transition")
val rotateAnimation by infiniteTransition.animateFloat(
initialValue = 0f,
targetValue = 360f,
animationSpec = infiniteRepeatable(
animation = tween(
durationMillis = animationDuration,
easing = LinearEasing
)
), label = "loading animation"
)
CircularProgressIndicator(
modifier = Modifier
.size(size = indicatorSize)
.rotate(degrees = rotateAnimation)
.border(
width = 12.dp,
brush = Brush.sweepGradient(circleColors),
shape = CircleShape
),
progress = 1f,
strokeWidth = 12.dp,
color = colorResource(id = R.color.progress_track)
)
}