How to create jetpack compose card?
Basically three types of cards are widely used in Android App Filled, Elevated Card and Outlined Card,
Filled cards - A card with background colors.
Elevated cards - Elevated cards keep content with a drop shadow that provide more separation from the background than filled cards, but less than outlined cards.
Outlined Card - Outlined cards keep content with a visual boundary around the container. This can provide greater emphasis than the other types.
In this tutorial we will learn to create jetpack compose card
A simple card with OnClick functionCard(
onClick = {
Toast.makeText(context, "Jetpack Compose Card", Toast.LENGTH_SHORT).show()
},
modifier = Modifier
.padding(20.dp)
.size(width = 220.dp, height = 120.dp)
) {
Box(Modifier.fillMaxSize()) {
Text("Clickable Card", Modifier.align(Alignment.Center))
}
}
Some important parameters for card
elevation - We use it to controls the the shadow effect below the cards.
onClick -We used it to response when the cards are clicked.
shape - defines the shape of the card's container, border (when border is not null), and shadow (when using elevation).
Steps : -

MainActivity
Cards
OUTPUT : -

