https://kotlinlang.org logo
Title
a

Alex Styl

04/24/2023, 3:37 PM
how can i draw the different sides of a border with a different color? I would like to draw the top and left sides a different color to the right and bottom. this is fairly easy to do with design tools (such as figma).
o

Oleksandr Balan

04/24/2023, 4:38 PM
I think you could mimic it with several background modifiers, something like that:
@Preview
@Composable
fun BordersPreview() {
    val borderWidth = 8.dp
    val borderShape = RectangleShape
    Box(
        modifier = Modifier
            .size(100.dp)
            .background(Color.Cyan, borderShape)
            .padding(start = borderWidth, top = borderWidth)
            .background(Color.Yellow, borderShape)
            .padding(end = borderWidth, bottom = borderWidth)
            .background(Color.White, borderShape)
    )
}
With rounded corner shape it looks weird, but cool as for me 😅
a

Alex Styl

04/26/2023, 3:30 AM
wow. impressed you can do that