Artem
09/13/2021, 1:44 PMText()
in case when text could be any size (multiple lines too)?
drawLine(maxWidth, maxHeight)
won’t work for me, cause it increase Box
with Text
to full screen. Maybe possible to measure text and then drawLine?Javier
09/13/2021, 1:45 PMArtem
09/13/2021, 1:48 PMNicolas Acart
09/13/2021, 2:25 PM@Composable
fun CrossedLine(content: @Composable () -> Unit) {
Box(
modifier = Modifier
.drawWithContent {
//Draw the content before the line
//You can put this line after the scale block to put the line behind
//(or use drawBehind)
this.drawContent()
//You can change the scale if you want
scale(scale = 1f) {
drawPath(
path = Path().apply {
reset()
//Draw the line
lineTo(size.width, size.height)
},
//The color of the line
color = Color.Black,
//2dp of thickness
style = Stroke(width = 2.dp.toPx())
)
}
}
// If you want to add some padding (the line will go to the padding)
.padding(start = 0.dp, top = 0.dp, end = 0.dp, bottom = 0.dp)
) {
content()
}
}