Jetpack Compose: как нарисовать такой путь

Таким образом я хотел показать два момента:

Jetpack Compose: как нарисовать такой путь

Есть ли какая-то ссылка, которую я могу найти?

1
0
150
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Просто используйте Canvas и нарисуйте 2 круга и 1 линию.

Canvas(Modifier.fillMaxSize()){

    val radius = 64f //radius of circles
    val strokeWidth = 20f 
    val lineHeight = 300f
    val centerFirstCircle = Offset(100f, 100f)

    drawCircle(
        color = Color.Red,
        radius = radius,
        center = centerFirstCircle,
        style = Stroke(width = strokeWidth)
    )

    //calculate the start and end of the vertical line
    val xLine = centerFirstCircle.x
    val yLine = centerFirstCircle.y + radius + strokeWidth/2

    drawLine(
        color = Red,
        start = Offset(xLine, yLine),
        end = Offset(xLine , yLine + lineHeight),
        strokeWidth = strokeWidth
    )

    //calculate the center of the second circle
    val centerSecondCircle = Offset( centerFirstCircle.x,
        centerFirstCircle.y + (radius*2) + lineHeight + (strokeWidth/2 *2) )

    drawCircle(
        color = Color.Red,
        radius = radius,
        center = centerSecondCircle,
        style = Stroke(width = strokeWidth)
    )
}

Другие вопросы по теме