Does this work as intended or is it a bug? I expe...
# compose
a
Does this work as intended or is it a bug? I expect the images to be drawn next to each other (horizontally) (due to the equal weights), but they are drawn below each other.
Copy code
FlowRow {
        Image(
            painter = painterResource(R.drawable.image),
            contentDescription = null,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .weight(1f)
                .height(height = 200.dp)
        )
        Image(
            painter = painterResource(R.drawable.image),
            contentDescription = null,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .weight(1f)
                .height(height = 200.dp)
        )
    }
Opened an Issue as a workaround, you can place the Image in a Box and use
matchParentSize()
on the image
l
Is this image a bitmap? Could you share the image you are testing with? It’s possible it is related to the intrinsic size of the image
a
@Louis Pullen-Freilich [G] I tried with 2 different ways. 1) load it from drawable and 2) use coil asyncimage painter to load it from unsplash. same situation
l
https://developer.android.com/develop/ui/compose/layouts/flow#item-weights So, weight in a flow layout basically only applies if the items end up in the same row / column. In this case, because the image (intrinsically) is much bigger, it will be placed into its own row since there isn’t space for anything else Depending on what your intention is, there are a few ways you could express this differently (the page I linked has some guidance), but this is working as expected from the flow layout side. In this simple snippet what you described is just a Row with two weight modifiers, you don’t want any flowing behavior here at all
107 Views