gpt4 book ai didi

android - Jetpack compose DropdownMenu 带有圆角

转载 作者:行者123 更新时间:2023-12-04 23:52:02 40 4
gpt4 key购买 nike

您好,我不知道如何在 jetpack compose 1.0.0-beta02 中制作切角菜单.我尝试用表面包装 while 菜单,但它没有用。

    TopAppBar(
modifier = Modifier
.statusBarsPadding(),
title = {
Text(text = "Title")
},
actions = {
var menuExpanded by remember { mutableStateOf(false) }

IconButton(onClick = { menuExpanded = true }) {
Icon(Icons.Default.MoreVert, contentDescription = null)
}

DropdownMenu(
expanded = menuExpanded,
onDismissRequest = {
menuExpanded = false
},
) {
DropdownMenuItem(onClick = {}) {
Text("Item 2")
}
}
},
)

这给了我
No Cut corners
但是我 需要这样的东西 , 它是四舍五入的。
menu with Material Theming

最佳答案

DropdownMenu 使用的默认形状由定义
medium shapes 中的属性用于MaterialTheme (检查你的主题)。

val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp), //<- used by `DropdownMenu`
large = RoundedCornerShape(0.dp)
)
您可以在主题中更改此值,也可以仅在 DropdownMenu 中覆盖中等形状。 .
就像是:
    MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))) {
DropdownMenu(
expanded = menuExpanded,
onDismissRequest = {
menuExpanded = false
}
) {
DropdownMenuItem(onClick = {}) {
Text("Item 2")
}
DropdownMenuItem(onClick = {}) {
Text("Item 3")
}
}
}
enter image description here

关于android - Jetpack compose DropdownMenu 带有圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66781028/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com