Object

CardDefaults

Contains the default values used by Card

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
public object CardDefaults

Contains the default values used by Card

Functions

cardBackgroundPainter

@Composable
public fun cardBackgroundPainter(
    startBackgroundColor: Color =
        MaterialTheme.colors.primary
            .copy(alpha = 0.30f)
            .compositeOver(MaterialTheme.colors.background),
    endBackgroundColor: Color =
        MaterialTheme.colors.onSurfaceVariant
            .copy(alpha = 0.20f)
            .compositeOver(MaterialTheme.colors.background),
    gradientDirection: LayoutDirection = LocalLayoutDirection.current,
): Painter

Creates a Painter for background colors for a Card. Cards typically have a linear gradient for a background. The gradient will be between startBackgroundColor and endBackgroundColor and at an angle of 45 degrees.

Cards should have a content color that contrasts with the background gradient.

Parameters

startBackgroundColor The background color used at the start of the gradient of this Card
endBackgroundColor The background color used at the end of the gradient of this Card
gradientDirection Whether the cards gradient should be start to end (indicated by LayoutDirection.Ltr) or end to start (indicated by LayoutDirection.Rtl).

imageWithScrimBackgroundPainter

@Composable
public fun imageWithScrimBackgroundPainter(
    backgroundImagePainter: Painter,
    backgroundImageScrimBrush: Brush =
        Brush.linearGradient(
            colors =
                listOf(
                    MaterialTheme.colors.surface.copy(alpha = 1.0f),
                    MaterialTheme.colors.surface.copy(alpha = 0f),
                )
        ),
): Painter

Creates a Painter for the background of a Card that displays an Image with a scrim over the image to make sure that any content above the background will be legible.

An Image background is a means to reinforce the meaning of information in a Card, e.g. To help to contextualize the information in a TitleCard

Cards should have a content color that contrasts with the background image and scrim

Parameters

backgroundImagePainter The Painter to use to draw the background of the Card
backgroundImageScrimBrush The Brush to use to paint a scrim over the background image to ensure that any text drawn over the image is legible