My Imports
Its asking me to import Focus request but i want to use the createRef() for Constraint layout reference
I'm using this version: "androidx.constraintlayout:constraintlayout-compose:1.0.0-rc01"
It's too late but I got the same problem and found the answer.
I forgot to surround createRefs by ConstraintLayout. It should be like this.
ConstraintLayout {
val (button, text) = createRefs()
Button(
onClick = { /* Do something */ },
modifier = Modifier.constrainAs(button) {
top.linkTo(parent.top, margin = 16.dp)
}
) {
Text("Button")
}
Text("Text", Modifier.constrainAs(text) {
top.linkTo(button.bottom, margin = 16.dp)
})
}
and you should import this.
import androidx.constraintlayout.compose.ConstraintLayout
I hope this helps you
When you want to write your "ConstraintSet" be careful not to add any other implementation of "androidx.compose
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With