我正在尝试使用 drawCircle
为圆形绘图设置动画。在 Canvas
如下:
drawCircle(
color = Color.Black,
radius = 200f * animatableCircle.value,
center = Offset(size.width / 4, size.height / 4),
style = Stroke(2f)
)
看起来不像是在画圆,而是圆从中心开始按比例缩放。是否可以实现类似于
CircularProgressIndicator
的沿半径绘制圆的效果?如图所示?最佳答案
只是为了完成 @Varsha Kulkarni 发布的代码: (+1)
val radius = 200f
val animateFloat = remember { Animatable(0f) }
LaunchedEffect(animateFloat) {
animateFloat.animateTo(
targetValue = 1f,
animationSpec = tween(durationMillis = 3000, easing = LinearEasing))
}
Canvas(modifier = Modifier.fillMaxSize()){
drawArc(
color = Color.Black,
startAngle = 0f,
sweepAngle = 360f * animateFloat.value,
useCenter = false,
topLeft = Offset(size.width / 4, size.height / 4),
size = Size(radius * 2 ,
radius * 2),
style = Stroke(2.0f))
}
关于android - 在 Jetpack compose 中绘制动画圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67080502/