Prateek Kumar
03/21/2023, 5:53 PMPrateek Kumar
03/21/2023, 6:08 PMMR3Y
03/21/2023, 6:30 PMCard(
modifier = Modifier
.border(width = 4.dp, color = MarrowTheme.colors.onSurfaceBlue)
.padding(start = 4.dp)
.fillMaxWidth()
) {
// card content...
}
your current solution is considered an anti-pattern called "Recomposition loop" because it wastes at least 1 frame.
Read more about it in the documentation: https://developer.android.com/jetpack/compose/phases#recomp-loopPrateek Kumar
03/21/2023, 7:10 PMStylianos Gakis
03/21/2023, 9:17 PMCard() {
Row(fillMaxSize) {
Box(fillMaxHeight.width(4.dp).background(Color.Blue)
YourCardContent()
}
}
MR3Y
03/21/2023, 10:31 PMborder
is applying some paddings/offsets internally, I think if you want one side border, you would do it manually using one of drawX
modifiers:
val borderColor = MarrowTheme.colors.onSurfaceBlue
val borderWidth = with(LocalDensity.current) {
4.dp.toPx()
}
Card(
modifier = modifier
.fillMaxSize()
.drawWithCache {
onDrawBehind {
drawRect(color = borderColor, size = Size(width = borderWidth, size.height))
}
}
.padding(start = 4.dp)
.fillMaxWidth()
) {
// card content...
}
haven't tested it, but I think it should achieve the desired resultMR3Y
03/21/2023, 10:35 PMStylianos Gakis
03/21/2023, 10:38 PMPrateek Kumar
03/22/2023, 2:23 AMPrateek Kumar
03/22/2023, 3:11 AM