这就是我想要实现的目标:

因此,我连续创建了 2 个圆形按钮,并根据是否选择它们提供了不同的背景颜色。目标是创建一种选项卡/切换的错觉。
未选中的按钮将具有与该行的背景颜色相同的颜色。不幸的是,由于行是矩形形状,因此在拐角处有残留空间,但仍然显示背景颜色。


这是我的按钮代码
val cornerRadius = 20.dp
var selectedIndex by remember { mutableStateOf(0)}
val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp.dp
val items = listOf(
OutlinedButton(onClick = { /*TODO*/ }) {
},
OutlinedButton(onClick = { /*TODO*/ }) {
})
Row(
modifier = Modifier
.padding(top = 8.dp)
.wrapContentHeight()
.width(screenWidth).background(color = Color.Gray).clip(shape = RoundedCornerShape(20.dp))
) {
// Spacer(modifier = Modifier.weight(1f))
items.forEachIndexed { index, item ->
OutlinedButton(modifier = Modifier
.wrapContentHeight()
.width(screenWidth/2),
shape = when (index) {
// left outer button …Run Code Online (Sandbox Code Playgroud)