Hi again, still in a `Row`, how can I set a requir...
# compose-desktop
a
Hi again, still in a
Row
, how can I set a required width for the second element, but have the first element just have a minimum size but take the maximum size available without overlapping the second element ?
Because for now I have the row with the first element have
Modifier.fillMaxWidth()
and the second
Modifier.requiredWidth(150.dp)
but they are overlapping
j
try weight()
a
then the second element totally disappear
f
Use width(IntrinsicSize.max) instead of fillMaxWidth
I actually have a custom layout that does the exact same thing you mentioned, but for Column
a
I get this error
Copy code
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Asking for intrinsic measurements of SubcomposeLayout layouts is not supported. This includes components that are built on top of SubcomposeLayout, such as lazy lists, BoxWithConstraints, TabRow, etc. To mitigate this:
- if intrinsic measurements are used to achieve 'match parent' sizing,, consider replacing the parent of the component with a custom layout which controls the order in which children are measured, making intrinsic measurement not needed
- adding a size modifier to the component, in order to fast return the queried intrinsic measurement.
But I'm not exactly sure how to fix it
t
Copy code
Row {
    Thing1(Modifier.weight(1f))
    Thing2(Modifier.width(150.dp)
}
This should make Thing2 exactly 150.dp wide and have Thing1 take up all the remaining space.
weight(Float)
determines how the unused space is divided up between participating composables. If only one composable specifies it, it gets all the available unused space. Otherwise, the composables divide the space according to their weight (
1f/1f -> 50%/50%
,
1f/2f -> 33.3%/66.6%
,
2f/2f -> 50%/50%
,
1f/2f/3f -> 16.6%, 33.3%, 50%
, you get the idea).
a
I don't find the
weight
method, intellij don't want to import it, where it is located ?
oh okay it has to be a parameter of my composable
It works thanks !
👍 1