ChargeMap / Compose-NumberPicker

Jetpack Compose Number Picker
235 stars 33 forks source link

Layout bug when in ConstraintLayout #5

Open wingsum93 opened 2 years ago

wingsum93 commented 2 years ago

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")
                    }
                }
LimitLost commented 2 years ago

Those Big Cyan Bars Are Caused By Size modifier