问题描述
如何在 Jetpack Compose 中更改 Row
边框的形状?
我正在创建一个自定义按钮,在 Jetpack Compose 中,我使用 Row
来水平对齐内容。我需要此自定义按钮具有以下格式:
然而,我的 Jetpack Compose 代码呈现出以下元素,没有圆角:
下面是此 Compose 函数的代码:
@Composable
fun LargeQuantityButton(
modifier: Modifier = Modifier,
onPlusClick: () -> Unit,
onMinusClick: () -> Unit,
text: String,
) = Row(
modifier = modifier
.border(
border = ButtonDefaults.outlinedBorder,
shape = RoundedCornerShape(4.dp)
),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
RemoveIcon(action = onMinusClick)
Text(
text = text,
fontWeight = FontWeight.W400
)
AddIcon(action = onPlusClick)
}
我的尝试失败了
我试着在Modifier
的border
调用之后立即添加clip
函数调用,像这样:
@Composable
fun LargeQuantityButton(
modifier: Modifier = Modifier,
onPlusClick: () -> Unit,
onMinusClick: () -> Unit,
text: String,
) = Row(
modifier = modifier
.border(border = ButtonDefaults.outlinedBorder)
.clip(shape = RoundedCornerShape(4.dp)),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
RemoveIcon(action = onMinusClick)
Text(
text = text,
fontWeight = FontWeight.W400
)
AddIcon(action = onPlusClick)
}
但是它也没有起作用。