基于compose_version=1.1.0-beta01版本 参数如下:
DropdownMenu(
expanded: Boolean,//菜单栏状态
onDismissRequest: () -> Unit,//菜单栏被关闭回调
modifier: Modifier = Modifier,//布局修饰
offset: DpOffset = DpOffset(0.dp, 0.dp),//要添加到菜单位置的偏移量
properties: PopupProperties = PopupProperties(focusable = true),//自定义的弹出框
content: @Composable ColumnScope.() -> Unit//内容
)
简单使用:
@Composable
fun DropDownTest() {
val context = LocalContext.current
var expanded = remember {
mutableStateOf(false)
}
val items = listOf("A", "B", "C", "D", "E")
Box(
Modifier
.fillMaxSize()
.padding(10.dp)
.wrapContentSize(Alignment.TopStart)
) {
TextButton(
onClick = {
expanded.value = true
},