CarIcon.Builder


class CarIcon.Builder


A builder of CarIcon.

Summary

Public constructors

Builder(carIcon: CarIcon)

Returns a Builder instance configured with the same data as the given CarIcon instance.

Creates a Builder instance using the given IconCompat.

Builder(icon: IconCompat, style: CarIconStyle)

Creates a Builder instance using the given IconCompat and explicit CarIconStyle.

Public functions

CarIcon

Constructs the CarIcon defined by this builder.

CarIcon.Builder

Sets the style of the icon to the given CarIconStyle.

CarIcon.Builder

This function is deprecated.

Use setStyle and provide a tint via setTint, or use createTintedIcon instead.

Public constructors

Builder

Added in 1.0.0
Builder(carIcon: CarIcon)

Returns a Builder instance configured with the same data as the given CarIcon instance.

Throws
java.lang.NullPointerException

if icon is null

Builder

Added in 1.0.0
Builder(icon: IconCompat)

Creates a Builder instance using the given IconCompat.

The following types are supported:

TYPE_URI is only supported in templates that explicitly allow it. In those cases, the appropriate APIs will be documented to indicate this.

For TYPE_URI, the URI's scheme must be SCHEME_CONTENT.

If the icon image is loaded from URI, it may be cached on the host side. Changing the contents of the URI will result in the host showing a stale image.

Note: It is recommended to use createTintedIcon, createOriginalIcon, or Builder to explicitly specify visual styling behavior. This constructor will be deprecated in a future release.

Throws
java.lang.IllegalArgumentException

if icon's URI scheme is not supported

java.lang.NullPointerException

if icon is null

Builder

Added in 1.9.0-alpha02
Builder(icon: IconCompat, style: CarIconStyle)

Creates a Builder instance using the given IconCompat and explicit CarIconStyle.

The following types are supported:

TYPE_URI is only supported in templates that explicitly allow it. In those cases, the appropriate APIs will be documented to indicate this.

For TYPE_URI, the URI's scheme must be SCHEME_CONTENT.

If the icon image is loaded from URI, it may be cached on the host side. Changing the contents of the URI will result in the host showing a stale image.

Select the appropriate style depending on the asset:

  • Use TINTED for icons that should be automatically tinted by the vehicle theme or assigned a custom tint via setTint.
  • Use ORIGINAL for icons that must retain their original colors without host-side tinting (e.g., user avatars, media album art, photos, or un-tinted logos).
Parameters
icon: IconCompat

The base icon or image graphic.

style: CarIconStyle

The explicit style contract dictating tinting behavior and optional geometric shaping.

Throws
java.lang.IllegalArgumentException

if icon's URI scheme is not supported

java.lang.NullPointerException

if icon or style is null

Public functions

build

Added in 1.0.0
fun build(): CarIcon

Constructs the CarIcon defined by this builder.

setStyle

Added in 1.9.0-alpha02
fun setStyle(style: CarIconStyle): CarIcon.Builder

Sets the style of the icon to the given CarIconStyle.

Select the appropriate style depending on the asset:

  • Use TINTED for icons that should be automatically tinted by the vehicle theme or assigned a custom tint via setTint.
  • Use ORIGINAL for icons that must retain their original colors without host-side tinting (e.g., user avatars, media album art, photos, or un-tinted logos).
Parameters
style: CarIconStyle

The explicit style contract dictating tinting behavior and optional geometric shaping.

setTint

Added in 1.0.0
Deprecated in 1.9.0-alpha02
fun setTint(tint: CarColor): CarIcon.Builder

Sets the tint of the icon to the given CarColor.

This tint overrides the tint set through setTint in the backing IconCompat with a CarColor tint. The tint set through setTint is not guaranteed to be applied if the CarIcon tint is not set.

The tint mode used to blend this color is SRC_IN.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

Throws
java.lang.NullPointerException

if tint is null