https://kotlinlang.org logo
#compose
Title
# compose
m

Mario Andhika

12/07/2023, 6:40 AM
Why does wrapContentSize not want to expand vertical-scrollable Column? But no problems with shrinking. Code in thread
Copy code
Column(
    Modifier
        .wrapContentSize()
        .verticalScroll(rememberScrollState())
    , horizontalAlignment = Alignment.CenterHorizontally
) {
    when (state) {
        SurveyDialogState.Prompt -> {
            Text("Want to fill survey?")
            Row(modifier = Modifier.fillMaxWidth().padding(12.dp), horizontalArrangement = Arrangement.SpaceBetween) {
                Button({ showDialog = false }) {
                    Text("Skip")
                }
                Button(
                    { state = SurveyDialogState.Questions }
                ) {
                    Text("Fill Survey")
                }
            }
        }
        SurveyDialogState.Questions -> {
            val questions = listOf(
                "",
                "",
                "",
                "",
                ""
            )
            questions.forEach {
                Text(modifier = Modifier.padding(12.dp), text = it)
                OutlinedTextField(value = "", onValueChange = {}, minLines = 2)
            }
            Button(
                {
                    scope.launch {
                        state = SurveyDialogState.Loading
                        delay(2000)
                        state = SurveyDialogState.Thanks
                    }
                },
                colors = ButtonDefaults.buttonColors(containerColor = ZealsMainBg)) {
                Text("Submit")
            }
        }
        SurveyDialogState.Loading -> {
            Column(Modifier.padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally) {
                Text("Sending your answers...")
                CircularProgressIndicator()
            }
        }
        SurveyDialogState.Thanks -> {
            Column(Modifier.padding(20.dp)) {
                Text("Thanks")
                Row(modifier = Modifier.fillMaxWidth().padding(12.dp), horizontalArrangement = Arrangement.End) {
                    Button({ showDialog = false }) {
                        Text("Close")
                    }
                }
            }
        }
    }
}
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 3:54 PM
wrapContentHeight
sets the minimum height to zero. If you want to make the container fill the height, use
fillMaxHeight
to set the minimum height to the incoming max height constraint.
m

Mario Andhika

12/08/2023, 7:41 AM
I have 4 states of varying supposed heights. 200dp, 600dp, 50dp, 150dp. In practice though, it wouldn’t expand to 600dp. So the heights in practice would’ve been 200dp, 200dp, 50dp, 150dp. If I remove the 200dp state, however, then it would actually show 600dp, then 50dp and 150 dp, which is how it’s supposed to be. But adding the first state with 200dp height caused it to not want to expand beyond 200dp, even though it should at the second state
z

Zach Klippenstein (he/him) [MOD]

12/08/2023, 7:49 PM
I’m not entirely sure I understand the problem. Is it that a layout isn’t being invalidated after another node changes size?