ImageKt

Added in 1.3.0-alpha06

public final class ImageKt


Summary

Public methods

static final @NonNull LayoutElementBuilders.LayoutElement
avatarImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutModifier modifier,
    int contentScaleMode
)

Returns the avatar image with the defined style.

static final @NonNull LayoutElementBuilders.LayoutElement
backgroundImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull LayoutModifier modifier,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor overlayColor,
    @NonNull DimensionBuilders.ContainerDimension overlayWidth,
    @NonNull DimensionBuilders.ContainerDimension overlayHeight,
    int contentScaleMode
)

Returns the image background with the defined style.

Public methods

public static final @NonNull LayoutElementBuilders.LayoutElement avatarImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutModifier modifier,
    int contentScaleMode
)

Returns the avatar image with the defined style.

Material components such as appCard provide proper defaults for the small avatar image. In order to take advantage of those defaults, this should be used with the resource ID only: avatarImage("id").

Parameters
@NonNull String protoLayoutResourceId

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

@NonNull DimensionBuilders.ImageDimension width

The width of an image. Usually, a small image that fit into the component's slot.

@NonNull DimensionBuilders.ImageDimension height

The height of an image. Usually, a small image that fit into the component's slot.

@NonNull LayoutModifier modifier

Modifiers to set to this element.

int contentScaleMode

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

public static final @NonNull LayoutElementBuilders.LayoutElement backgroundImage(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull LayoutModifier modifier,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor overlayColor,
    @NonNull DimensionBuilders.ContainerDimension overlayWidth,
    @NonNull DimensionBuilders.ContainerDimension overlayHeight,
    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 image. Node that, this is not an Android resource id.

@NonNull LayoutModifier modifier

Modifiers to set to this element.

@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 LayoutColor 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

int contentScaleMode

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