Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Layout bug when in ConstraintLayout #5

@wingsum93

Description

@wingsum93

Layout bug when in ConstraintLayout (compose)

Here is the screenshot:
螢幕截圖 2022-02-04 上午11 00 52

Attached my compose layout code:

ConstraintLayout(
                    modifier = Modifier.fillMaxSize(),
                ) {
                    val (title, picker, btn) = createRefs()
                    var pickerValue by remember { mutableStateOf(2) }
                    Text(text = "Select Next No of People", modifier = Modifier.constrainAs(title) {
                        centerHorizontallyTo(parent)
                        top.linkTo(parent.top)
                    })
                    NumberPicker(
                        modifier = Modifier
                            .constrainAs(picker) {
                                centerHorizontallyTo(parent)
                                top.linkTo(title.bottom)
                            }
                            .size(100.dp, 200.dp),
                        value = pickerValue,
                        range = 0..10,
                        dividersColor = Color.Cyan,
                        onValueChange = {
                            pickerValue = it
                        }
                    )

                    Button(onClick = { /*TODO*/ }, modifier = Modifier.constrainAs(btn) {
                        centerHorizontallyTo(parent)
                        bottom.linkTo(parent.bottom)
                    }) {
                        Text(text = "Click")
                    }
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions