之前,我在这里发帖,我用谷歌搜索了很多。我发现以下内容:
MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))){}
来自以下SO帖子:Jetpack compose DropdownMenu With rounded Corners
编辑:我正在使用Material Design v3。
MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))) {
IconButton(
onClick = { showMenu = !showMenu }) {
Icon(imageVector = Icons.Outlined.MoreVert, contentDescription = "")
DropdownMenu(
expanded = showMenu,
onDismissRequest = { showMenu = false },
modifier = Modifier.background(MaterialTheme.colorScheme.background).padding(4.dp)
) {
DropdownMenuItem(text = { Text("Refresh", fontSize = 16.sp) }, onClick = { showMenu = false })
DropdownMenuItem(text = { Text("Settings", fontSize = 16.sp) }, onClick = { showMenu = false })
Divider(color = Color.LightGray, thickness = 1.dp)
DropdownMenuItem(text = { Text("Send Feedback", fontSize = 16.sp) }, onClick = { showMenu = false })
}
}
}
目前它产生以下输出:
确实有一定的边界半径,但没有达到预期的目标。来自第三方应用程序的第二个屏幕截图确实具有我想要获得的边框半径。
根据 compsoe 1.7.5 现在支持使用形状道具自定义专用形状
@Composable
fun DropdownMenu(
expanded: Boolean,
onDismissRequest: () -> Unit,
modifier: Modifier = Modifier,
offset: DpOffset = DpOffset(0.dp, 0.dp),
scrollState: ScrollState = rememberScrollState(),
properties: PopupProperties = DefaultMenuProperties,
shape: Shape = MenuDefaults.shape,
containerColor: Color = MenuDefaults.containerColor,
tonalElevation: Dp = MenuDefaults.TonalElevation,
shadowElevation: Dp = MenuDefaults.ShadowElevation,
border: BorderStroke? = null,
content: @Composable ColumnScope.() -> Unit
): Unit