Canvas(modifier = Modifier.fillMaxSize(), onDraw = {
//draw a circle
drawCircle(color = Red,
center = Offset(120f,120f),
radius = 100f)
//draw a simple line.In your case you can use a Bezier curves
val strokePath = Path().apply {
moveTo (220f, 120f)
lineTo (size.width - 220f, 400f)
}
drawPath(
path = strokePath,
color = Blue,
style = Stroke(
width = 3.dp.toPx(),
cap = StrokeCap.Round
)
)
//draw the 2nd circle
drawCircle(color = Color.Red,
center = Offset(size.width - 120f,400f),
radius = 100f)
})
1条答案
按热度按时间cnjp1d6j1#
您可以使用
Canvas
绘制圆和直线。比如:
要启用可单击区域,可以为每个圆定义一个
Rect
列表,然后将pointerInput
修改器应用于Canvas
。比如: