Hi everyone, I have recently updated `compose-bom`...
# compose-android
j
Hi everyone, I have recently updated
compose-bom
to
2023.03.00
from
2022.12.00
, and my
AndroidView
inside
constraintLayout
has started breaking. can someone help me figuring out the issue? attaching screenshot and minimal code to reproduce the issue in the thread
code:
Copy code
@Composable
fun RandomColorAndroidView(modifier: Modifier = Modifier) {
    AndroidView(
        modifier = modifier,
        factory = { context ->
            FrameLayout(context).apply {
                setBackgroundColor(getRandomColor())
            }
        },
        update = { view ->
            // update the view if needed
        },
    )
}

@Composable
fun RandomColorFrameLayoutsInConstraintLayout() {
    ConstraintLayout(
        modifier = Modifier
            .fillMaxSize()
            .background(MaterialTheme.colors.background)
    ) {
        val (androidView1Ref, androidView2Ref, androidView3Ref) = createRefs()

        RandomColorAndroidView(
            modifier = Modifier
                .size(50.dp)
                .constrainAs(androidView1Ref) {
                    start.linkTo(parent.start)
                    top.linkTo(<http://parent.top|parent.top>)
                    bottom.linkTo(parent.bottom)
                }
        )
        RandomColorAndroidView(
            modifier = Modifier
                .size(40.dp)
                .constrainAs(androidView2Ref) {
                    start.linkTo(androidView1Ref.end)
                    top.linkTo(<http://parent.top|parent.top>)
                    bottom.linkTo(parent.bottom)
                }
        )
        RandomColorAndroidView(
            modifier = Modifier
                .size(30.dp)
                .constrainAs(androidView3Ref) {
                    start.linkTo(androidView2Ref.end)
                    top.linkTo(<http://parent.top|parent.top>)
                    bottom.linkTo(parent.bottom)
                }
        )
    }
}

private fun getRandomColor(): Int {
    val hue = Random.nextInt(360)
    val saturation = Random.nextFloat()
    val value = Random.nextFloat()
    return ColorUtils.HSLToColor(floatArrayOf(hue.toFloat(), saturation, value))
}
output with
2022.12.00
output with
2023.03.00