oday
10/05/2022, 11:09 AMBox(
contentAlignment = Alignment.Center,
modifier = Modifier
.clip(RoundedCornerShape(10.dp))
.border(BorderStroke(2.dp, Color.Red))
.padding(10.dp),
) {
Text(
text = filter.name,
color = MaterialTheme.colors.Action,
)
}
output is this, the edges are cutting of for some reasonOleksandr Balan
10/05/2022, 11:24 AM.border()
modifier. Also I think .clip()
is not needed in this case.oday
10/05/2022, 11:56 AMSurface(
modifier = Modifier
.widthIn(0.dp, 144.dp)
.width(100.dp),
elevation = 8.dp,
shape = RoundedCornerShape(15.dp),
color = MaterialTheme.colors.Action.copy(alpha = 0.2f),
border = BorderStroke(
width = 1.dp,
color = when {
selected -> MaterialTheme.colors.Action
else -> MaterialTheme.colors.ForegroundMuted
}
)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Text(
modifier = Modifier
.padding(8.dp),
text = filter.name,
color = MaterialTheme.colors.Action,
textAlign = TextAlign.Center
)
Image(
painter = if (filter.enabled.value)
painterResource(id = R.drawable.ic_chevron_down_blue)
else
painterResource(id = R.drawable.ic_chevron_down_gray),
contentDescription = null
)
}
}
Oleksandr Balan
10/05/2022, 12:18 PMSurface
directly.
Which basically passes the shape to the .border
modifier for you 👇
> Surface.kt
Box(
modifier
.then(if (border != null) Modifier.border(border, shape) else Modifier)
...
) {
content()
}
oday
10/05/2022, 12:50 PModay
10/05/2022, 12:51 PModay
10/05/2022, 12:51 PMOleksandr Balan
10/05/2022, 12:54 PModay
10/05/2022, 12:55 PModay
10/05/2022, 12:55 PMjasu
10/06/2022, 5:49 AM