https://kotlinlang.org logo
#compose
Title
# compose
u

0xf1f1

03/06/2024, 11:49 PM
how do I make VerticalDivider a dotted line ?
s

Sean Proctor

03/07/2024, 12:07 AM
You can't with the version from M3, here's one you can pass a
pathEffect
to.
Copy code
@Composable
fun VerticalDivider(
    pathEffect: PathEffect,
    modifier: Modifier = Modifier,
    thickness: Dp = DividerDefaults.Thickness,
    color: Color = DividerDefaults.color,
) = Canvas(modifier.fillMaxHeight().width(thickness)) {
    drawLine(
        color = color,
        strokeWidth = thickness.toPx(),
        start = Offset(thickness.toPx() / 2, 0f),
        end = Offset(thickness.toPx() / 2, size.height),
        pathEffect = pathEffect,
    )
}
VerticalDivider(PathEffect.dashPathEffect(floatArrayOf(10f, 10f), 0f)
👍 1
u

0xf1f1

03/07/2024, 1:14 AM
thanks - how do I set the radious for each dot ?
s

Sean Proctor

03/07/2024, 3:31 AM
3 Views