【发布时间】:2022-01-21 05:25:14
【问题描述】:
我从 Kotlin 开始,我想知道如何在 Kotlin 中制作带有下拉菜单的表单。我做了这个,但看起来不太好。
代码:
var billingPeriodExpanded by remember { mutableStateOf(false) }
var selectedIndex by remember { mutableStateOf(0) }
OutlinedTextField(
value = billingPeriodItems[selectedIndex],
onValueChange = { selectedIndex = billingPeriodItems.indexOf(it) },
label = {
Column(modifier = Modifier.fillMaxSize()) {
ComposeMenu(
menuItems = billingPeriodItems,
menuExpandedState = billingPeriodExpanded,
seletedIndex = selectedIndex,
updateMenuExpandStatus = {
billingPeriodExpanded = true
},
onDismissMenuView = {
billingPeriodExpanded = false
},
onMenuItemclick = { index ->
selectedIndex = index
billingPeriodExpanded = false
}
)
}
},
singleLine = true,
modifier = Modifier.fillMaxWidth(0.8f)
)
它看起来是这样的:
here you can see how the drop-down menu is over the field and not inside of it
你知道我该如何解决吗?
【问题讨论】:
标签: android kotlin user-interface android-jetpack-compose