ImageKt

Added in 1.3.0-alpha05

public final class ImageKt


Summary

Public methods

static final @NonNull LayoutElementBuilders.LayoutElement
backgroundImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull ColorBuilders.ColorProp overlayColor,
    @NonNull DimensionBuilders.ContainerDimension overlayWidth,
    @NonNull DimensionBuilders.ContainerDimension overlayHeight,
    @NonNull ModifiersBuilders.Corner shape,
    int contentScaleMode
)

Returns the image background with the defined style.

Public methods

public static final @NonNull LayoutElementBuilders.LayoutElement backgroundImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull ColorBuilders.ColorProp overlayColor,
    @NonNull DimensionBuilders.ContainerDimension overlayWidth,
    @NonNull DimensionBuilders.ContainerDimension overlayHeight,
    @NonNull ModifiersBuilders.Corner shape,
    int contentScaleMode
)

Returns the image background with the defined style.

Material components provide proper defaults for the background image. In order to take advantage of those defaults, this should be used with the resource ID only: backgroundImage("id").

Parameters
@NonNull String protoLayoutResourceId

The protolayout resource id of the icon. Node that, this is not an Android resource id.

@NonNull DimensionBuilders.ImageDimension width

The width of an image. Usually, this matches the width of the parent component this is used in.

@NonNull DimensionBuilders.ImageDimension height

The height of an image. Usually, this matches the height of the parent component this is used in.

@NonNull ColorBuilders.ColorProp overlayColor

The color used to provide the overlay over the image for better readability. It's recommended to use ColorScheme.background color with 60% opacity.

@NonNull DimensionBuilders.ContainerDimension overlayWidth

The width of the overlay on top of the image background

@NonNull DimensionBuilders.ContainerDimension overlayHeight

The height of the overlay on top of the image background

@NonNull ModifiersBuilders.Corner shape

The shape of the corners for the image

int contentScaleMode

The content scale mode for the image to define how image will adapt to the given size