小编Abu*_*dig的帖子

如何在jetpack compose画布上为drawPath()设置动画

我使用 path.cubicTo() 方法画了一颗心

Canvas(modifier = Modifier.size(100.dp)) {
            val path = Path()
            path.moveTo(0f, size.height / 3)

            path.cubicTo(0f, 0f, size.width / 2, 0f, size.width / 2, size.height / 3)
            path.cubicTo(size.width / 2, 0f, size.width, 0f, size.width, size.height / 3)

            path.cubicTo(
                size.width,
                size.height * 2 / 3,
                size.width / 2,
                size.height,
                size.width / 2,
                size.height
            )
            path.cubicTo(
                0f,
                size.height * 2 / 3,
                0f,
                size.height / 2,
                0f,
                size.height / 3
            )
            drawPath(color = Color.Red, path = path, style = Stroke(5f))
        }
Run Code Online (Sandbox Code Playgroud)

我画的心 …

animation android android-canvas android-jetpack-compose android-jetpack-compose-canvas

3
推荐指数
1
解决办法
1773
查看次数