https://kotlinlang.org logo
Title
d

Dirk Seewald

08/02/2022, 8:13 PM
How would i let the row with the buttons match the width of the column without
fillMaxWidth()
because that would expand the column. The column doesn't have a fixed size. This is my code:
Box(propagateMinConstraints = true) {
                Column(Modifier.wrapContentWidth().padding(24.dp).background(Color.Green.copy(alpha = 0.5f))) {
                    Row(Modifier) {
                        CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.headlineMedium) {
                            title()
                        }
                    }
                    Spacer(Modifier.height(32.dp))

                    Box {
                        //rowConstraints = constraints
                        CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.bodyLarge) {
                            Column(verticalArrangement = Arrangement.Center) {
                                content()
                            }
                        }
                    }
                    Spacer(Modifier.height(32.dp))
                    Row(
                        Modifier.background(Color.Red.copy(alpha = 0.4f)),
                        horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)
                    ) {
                        dismissButton(scope)
                        confirmButton(scope)
                    }
                }
            }
c

Colton Idle

08/03/2022, 4:22 AM
People are using the 🧵emoji in order to ask you to move the bulk of your question into a thread. See: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616265877303000
I think what you want here is Intrinsics. I think you would set a width of Intrinsic.Min on the layout that contains the input field and buttons. and then on the buttons you can set fillMaxWidth (or maybe even weight(1f) and then it shouldn't increase the width. The docs here have a good example of how intrinsics work. https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements
d

Dirk Seewald

08/03/2022, 9:46 AM
This is the code:
Box(propagateMinConstraints = true) {
                Column(Modifier.wrapContentWidth().padding(24.dp).background(Color.Green.copy(alpha = 0.5f))) {
                    Row(Modifier) {
                        CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.headlineMedium) {
                            title()
                        }
                    }
                    Spacer(Modifier.height(32.dp))

                    Box {
                        //rowConstraints = constraints
                        CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.bodyLarge) {
                            Column(verticalArrangement = Arrangement.Center) {
                                content()
                            }
                        }
                    }
                    Spacer(Modifier.height(32.dp))
                    Row(
                        Modifier.background(Color.Red.copy(alpha = 0.4f)),
                        horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)
                    ) {
                        dismissButton(scope)
                        confirmButton(scope)
                    }
                }
            }
@Colton Idle Thank you that solved my problem
c

Colton Idle

08/03/2022, 12:36 PM
Awesome!