julioromano
03/04/2021, 10:30 PMBox {
One()
Two()
}
I have 2 composables inside a Box()
. I’d like the Box to set its size to the size of One()
and I’d also like that Two()
adapts its size to the size of One()
. Is this possible?Piotr Prus
03/04/2021, 10:33 PMjulioromano
03/04/2021, 10:35 PMTwo()
is the actual Box content (a bunch of Text composables neatly arranged in a few Rows and Columns).
One()
is the background image which should fill the the size occupied by Two()
.
Right now if I set `One()`’s modifier to fillMaxSize()
it will expand and take up the whole screen, but I’d just like for it to expand to the same size as Two()
.Dominaezzz
03/04/2021, 10:54 PMjulioromano
03/04/2021, 11:20 PMDominaezzz
03/04/2021, 11:22 PMjulioromano
03/04/2021, 11:23 PMpavi2410
03/05/2021, 3:44 AMArchie
03/05/2021, 3:58 AMLayout(...)
2. or
var oneSize by remember { mutableStateOf(IntSize(0, 0)) }
val dpWidth = with(density) { dropDownSize.width.toDp() }
val dpHeight = with(density) { dropDownSize.height.toDp() }
Box{
One(modifier = Modifier.onSizeChanged { oneSize = it })
Two(modifier = Modifier.size(width = dpWidth, height = dpHeight)
}