# IconKt

Added in 1.3.0

*** ** * ** ***


```
public final class IconKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` | `[icon](https://developer.android.com/reference/androidx/wear/protolayout/material3/IconKt#(androidx.wear.protolayout.material3.MaterialScope).icon(kotlin.String,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.types.LayoutColor))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html protoLayoutResourceId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension width, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension height, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/types/LayoutColor tintColor )` **This method is deprecated.** Use icon(ImageResource, String, ImageDimension, ImageDimension, LayoutColor) instead, in combination with \[androidx.wear.tiles.Material3TileService\] that creates scopes for you. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` | `https://developer.android.com/reference/androidx/wear/protolayout/material3/IconKt#(androidx.wear.protolayout.material3.MaterialScope).icon(androidx.wear.protolayout.ResourceBuilders.ImageResource,kotlin.String,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.types.LayoutColor)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/ResourceBuilders.ImageResource resource, https://developer.android.com/reference/java/lang/String.html protoLayoutResourceId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension width, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension height, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/types/LayoutColor tintColor )` Returns the icon components with the defined style which will be automatically registered as a resource. |

## Public methods

### icon

Artifact: [androidx.wear.protolayout:protolayout-material3](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material3/Icon.kt+function:icon) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0) Deprecated in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
public static final @NonNull LayoutElementBuilders.LayoutElement [icon](https://developer.android.com/reference/androidx/wear/protolayout/material3/IconKt#(androidx.wear.protolayout.material3.MaterialScope).icon(kotlin.String,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.DimensionBuilders.ImageDimension,androidx.wear.protolayout.types.LayoutColor))(
    @NonNull MaterialScope receiver,
    @NonNull String protoLayoutResourceId,
    @NonNull DimensionBuilders.ImageDimension width,
    @NonNull DimensionBuilders.ImageDimension height,
    @NonNull LayoutColor tintColor
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use icon(ImageResource, String, ImageDimension, ImageDimension, LayoutColor) instead, in combination with \[androidx.wear.tiles.Material3TileService\] that creates scopes for you.

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html protoLayoutResourceId` | The protolayout resource id of the icon. Note that, this is not an Android resource id. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension width` | The width of the icon. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension height` | The height of the icon. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/types/LayoutColor tintColor` | The color used to tint the icon. |

### icon

Artifact: [androidx.wear.protolayout:protolayout-material3](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material3/Icon.kt+function:icon) Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/ResourceBuilders.ImageResource resource` | An Image resource, used in the layout in the place of this element. |
| `https://developer.android.com/reference/java/lang/String.html protoLayoutResourceId` | The optional protolayout resource id of the icon. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension width` | The width of the icon. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension height` | The height of the icon. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/types/LayoutColor tintColor` | The color used to tint the icon. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if this method is called without `https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope` set to the `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope`, i.e. when `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#materialScopeWithResources(android.content.Context,androidx.wear.protolayout.ProtoLayoutScope,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)` wasn't used |