There is no priority over any Composable over another in Jetpack Compose when measuring inside a Layout
. Layout composable is basis for Column
, Row
and Box
.
To determine measurements of a composable in a Layout
measurable.measure(constraints)
is used to determine in which range(min-max) a Composable should be measured, depending on this range and content of Composable it can have width in this range.
Constraints
is a class that determines in which range a Measureable
should be measured.
You can check out Constraints section of this answer to be familiar with which size Modifier returns which Constraints
.
https://stackoverflow.com/a/73316247/5457853
Let's say parent returned minWidth = 0
, maxWidth=1000
Row enter code here
measures Composables without Modifier.weight()
first in order they are placed.
If Text
composable is in the first place, in your example it is, and its content reaches parent size and since it can be measured with the range above it can occupy all the space of parent while it reaches to Image
it forces it to be measured with parent width - width of Text
it become smaller until becoming 0px.
But when you add Modifier.weight()
to Text
, Image is measured with first and since its its content is in range between Contraints it's calculated with its own size then Text covers the remaining space since it has Modifier.weight()
with fill param is true by default.