I’m looking for a complete example of `SubComposeL...
# compose
k
I’m looking for a complete example of
SubComposeLayout
. The compose sample has given sort of Scaffold of it and I’m not able not understand its usage from it. The layout I’m trying to build is as follows: my approach was to use
Text
as “mainContent” and pass its dimensions to a
Canvas
“dependentContent” to draw those accompanying lines. Any other suggestions/approaches are welcome
a
I don't think you need
SubcomposeLayout
. You may want to check intrinsics: https://developer.android.com/codelabs/jetpack-compose-layouts#9.
k
How may I get to know the lengths of side lines using Intrinsics? The text could be of any length and need to have some inner padding as shown. Intrinsic might help if I had to cover rest of the portion from one side but in this case I’ve lines on both the sides and I need to know
Text
dimensions before drawing the first line itself. Could you share some snippet/pseudocode to show your idea? Thanks!
a
I didn’t see the picture. For that simply something like this should work:
Copy code
Row(verticalAlignment = Alignment.CenterVertically) {
    Divider(modifier = Modifier.weight(1f))
    Text(text = "Food")
    Divider(modifier = Modifier.weight(1f))
}
1