You can use the Divider
composable with the width(xx.dp)
modifier applying an intrinsic measurements to its parent container.
Something like:
Row(Modifier
.height(IntrinsicSize.Min) //intrinsic measurements
.fillMaxWidth()
.background(Color.Yellow)
) {
Text("First Text")
Divider(
color = Color.Red,
modifier = Modifier
.fillMaxHeight() //fill the max height
.width(1.dp)
)
Text("Second text")
}
As explained in the doc:
The Row composable’s
minIntrinsicHeight
will be the maximumminIntrinsicHeight
of its children. TheDivider
element’sminIntrinsicHeight
is0
as it doesn’t occupy space if no constraints are given; theTextField
minIntrinsicHeight
will be that of the content given a specific width. Therefore, theRow
element’s height constraint will be the maxminIntrinsicHeight
of theTextField
s content. TheDivider
will then expand its height to the height constraint given by theRow
.