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
Card
background color is defined by thebackgroundColor
property and not by thebackground
modifier. This property also has a default value =MaterialTheme.colors.surface
which is applied by default to theCard
. It is the reason of the difference in your code.If you want to achieve with the
Card
the same layout of theBox
you have to use:If you want a
Box
with elevation and a gradient as background you can use theshadow
modifier: