[英]Jetpack compose DropdownMenu With rounded Corners
Hello I can't figure out how to make a cut corners menu in jetpack compose 1.0.0-beta02
.您好,我不知道如何在 jetpack compose 1.0.0-beta02
中制作切角菜单。 I tried wrapping the while menu with a surface but It didn't work.我尝试用表面包装 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")
}
}
},
)
Which gives me这给了我
But I need something like this , which is rounded.但我需要这样的东西,它是四舍五入的。
With 1.0.0
the default shape used by the DropdownMenu
is defined by the medium
attribute in the shapes
used in the MaterialTheme
(check your theme).对于1.0.0
, DropdownMenu
使用的默认形状由MaterialTheme
中使用的shapes
中的medium
属性定义(检查您的主题)。
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp), //<- used by `DropdownMenu`
large = RoundedCornerShape(0.dp)
)
You can change this value in your theme or you can override the medium shape only in your DropdownMenu
.您可以在主题中更改此值,也可以仅在DropdownMenu
中覆盖中等形状。
Something like:就像是:
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")
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.