Reputation: 21
Tell me how to set a background color for Card (Jetpack Compose). The trouble is, my card is not filled entirely, but it has a stroke: look at this image But I wanna fill this card entirely. How to do it?
I tried to fix this problem as written here, and wrote the code like this:
Card(modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = Blue1),
shape = RoundedCornerShape(10.dp),
elevation = CardDefaults.cardElevation(defaultElevation = 5.dp))
The color was called Blue1.
Upvotes: 1
Views: 643
Reputation: 81
To set a background color for a Card in Jetpack Compose and ensure that the card is filled entirely, you can modify the code as follows:
Card(
modifier = Modifier.fillMaxWidth()
.background(Blue1, shape = RoundedCornerShape(10.dp)),
elevation = 5.dp
) {
// Content of the card
}
Upvotes: 0