Is there an explanation for why this
Card(
modifier =
Modifier
.background(
brush = Brush.horizontalGradient(
colors = listOf(
OrgFarmTheme.colors.secondary,
OrgFarmTheme.colors.onSecondary
)
)
)
.clip(RoundedCornerShape(10))
) {
...
}
while
Box(
modifier =
Modifier
.background(
brush = Brush.horizontalGradient(
colors = listOf(
OrgFarmTheme.colors.secondary,
OrgFarmTheme.colors.onSecondary
)
)
)
.clip(RoundedCornerShape(10))
) {
...
}
I have tried using the default shape parameter of the Card, but it renders the same.


The
Cardbackground color is defined by thebackgroundColorproperty and not by thebackgroundmodifier. This property also has a default value =MaterialTheme.colors.surfacewhich is applied by default to theCard. It is the reason of the difference in your code.If you want to achieve with the
Cardthe same layout of theBoxyou have to use:If you want a
Boxwith elevation and a gradient as background you can use theshadowmodifier: