IconKt

Added in 1.3.0

public final class IconKt


Summary

Public methods

static final @NonNull LayoutElementBuilders.LayoutElement
icon(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor tintColor
)

Returns the icon components with the defined style.

static final @NonNull LayoutElementBuilders.LayoutElement
icon(
    @NonNull MaterialScope receiver,
    @NonNull ResourceBuilders.ImageResource resource,
    String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor tintColor
)

Returns the icon components with the defined style which will be automatically registered as a resource.

Public methods

public static final @NonNull LayoutElementBuilders.LayoutElement icon(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor tintColor
)

Returns the icon components with the defined style.

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

Parameters
@NonNull String protoLayoutResourceId

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

@NonNull DimensionBuilders.ImageDimension width

The width of the icon.

@NonNull DimensionBuilders.ImageDimension height

The height of the icon.

@NonNull LayoutColor tintColor

The color used to tint the icon.

public static final @NonNull LayoutElementBuilders.LayoutElement icon(
    @NonNull MaterialScope receiver,
    @NonNull ResourceBuilders.ImageResource resource,
    String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor tintColor
)

Returns the icon components with the defined style which will be automatically registered as a resource.

Material components provide proper defaults for this icon. In order to take advantage of those, this should be used with the resource ID only: icon(imageResource).

Note that, by using this method, there's no need to register resource for Tiles in androidx.wear.tiles.TileService.onTileResourcesRequest.

Parameters
@NonNull ResourceBuilders.ImageResource resource

An Image resource, used in the layout in the place of this element.

String protoLayoutResourceId

The optional protolayout resource id of the icon.

@NonNull DimensionBuilders.ImageDimension width

The width of the icon.

@NonNull DimensionBuilders.ImageDimension height

The height of the icon.

@NonNull LayoutColor tintColor

The color used to tint the icon. @throws IllegalStateException if this method is called without androidx.wear.protolayout.ProtoLayoutScope set to the MaterialScope, i.e. when materialScopeWithResources wasn't used