Hello everyone, With the following code I want to...
# compose
m
Hello everyone, With the following code I want to draw a border on a box only at the top edge.
Copy code
@Composable
fun Greeting() {

    Box(
            modifier = Modifier.height(250.dp)
    ) {

        Box(
                modifier = Modifier
                        .align(Alignment.TopCenter)
                        .size(100.dp)
                        .border(3.dp, Color.Cyan)
        )

        Box(
                modifier = Modifier
                        .align(Alignment.BottomCenter)
                        .size(100.dp)
                        .border(3.dp, Color.Cyan, GenericShape { size ->

                            moveTo(0f, 0f)
                            lineTo(size.width, 0f)
                        })
        )
    }
}
As you can see in the screenshot, the border is drawn, but it does not have the right width and also not the right color. Maybe someone can explain me where my mistake is or how I can draw a corresponding border at the top edge. I used the current version of Compose and Kotlin.
r
You can use the Canvas composable to draw your border
n
You can also use
Modifier.drawWithContent
to draw the content first then draw the top border line on top of the content