Моя цель — сделать так, чтобы каждый DropdownMenuItem в сопровождающем ExpedDropdownMenu точно соответствовал этой высоте 48.dp для обеспечения единообразного визуального интервала.
Несмотря на попытку изменить contentPadding и применить Modifier.size, компоненты DropdownMenuItem по-прежнему кажутся выше, чем 48.дп.
Код: Выделить всё
@Composable
fun AutoCompleteTextFields(
modifier: Modifier = Modifier,
value: TextFieldValue,
onValueChange: (TextFieldValue) -> Unit,
genderList: List = listOf("Female", "Male"),
) {
var isExpanded by remember { mutableStateOf(false) }
Column(
modifier = modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
ExposedDropdownMenuBox(
expanded = isExpanded,
onExpandedChange = {
isExpanded = it
},
) {
Row(
modifier = Modifier.fillMaxWidth(),
) {
SpotifyTextField(
value = value,
onValueChange = {
onValueChange(it.copy(selection = TextRange(it.text.length)))
isExpanded = true
},
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded)
},
modifier = Modifier.menuAnchor(ExposedDropdownMenuAnchorType.SecondaryEditable),
)
}
ExposedDropdownMenu(
expanded = isExpanded,
onDismissRequest = { isExpanded = false },
matchAnchorWidth = true,
containerColor = MaterialTheme.colorScheme.tertiary,
shape = RoundedCornerShape(4.dp),
) {
filteredList.forEachIndexed { index, item ->
DropdownMenuItem(
text = {
Text(
item,
style =
MaterialTheme.typography.bodyLarge.copy(
color = Color.White,
),
)
},
onClick = {
onValueChange(
TextFieldValue(
filteredList[index],
TextRange(filteredList[index].length),
),
)
isExpanded = false
},
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
)
}
}
}
}

Подробнее здесь: https://stackoverflow.com/questions/798 ... wnmenuitem