I have a composable ExposedDropdownMenu similar to this.
ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = {
expanded = !expanded
}
) {
OutlinedTextField(
readOnly = true,
value = selected,
onValueChange = { },
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(
expanded = expanded
)
}
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = {
expanded = false
}
) {
options.forEach { selection ->
DropdownMenuItem(
onClick = {
selected = selection
expanded = false
}
) {
Text(text = selection)
}
}
}
}
The resulting view looks like this:

I'm trying to reduce the width of the the dropdown so it actually wraps around its widest menu option.
And I've already tried setting modifiers at all levels of the composition to ensure no child is widening the parent, but to no success.
Add Modifier.width(IntrinsicSize.Min) works for me:
ExposedDropdownMenu(
modifier = Modifier.width(IntrinsicSize.Min),//Here
expanded = expanded,
onDismissRequest = { expanded = false },
) {
//... items here
}
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