如何使用Jetpack Compose实现中心带图标的圆形OutlinedButton
Compose 圆形图标按钮实现问题
尝试在界面中实现中心放置图标、无文字的圆形轮廓按钮,最初基于OutlinedButton编写了如下代码:
OutlinedButton( onClick = { /*TODO*/ }, shape = CircleShape, border = BorderStroke(1.dp, Color.Blue) ) { Icon(Icons.Default.Add, contentDescription = "content description") }
实际运行后生成的按钮呈椭圆形,效果如下:
后续调整实现方案,改用IconButton编写代码:
IconButton( onClick = { }, modifier = Modifier .clip(CircleShape) .border(1.dp, Color.Red) ) { Icon( Icons.Default.Add, contentDescription = "content description", tint = Color.Red ) }
这版代码的运行效果如下:
内容的提问来源于stack exchange,提问作者Gabriele Mariotti
相关产品推荐
相关产品推荐

