CarIcon.Builder


public final class CarIcon.Builder


A builder of CarIcon.

Summary

Public constructors

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

Creates a Builder instance using the given IconCompat.

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

Public methods

@NonNull CarIcon

Constructs the CarIcon defined by this builder.

@NonNull CarIcon.Builder

Sets the style of the icon to the given CarIconStyle.

@NonNull CarIcon.Builder

This method is deprecated.

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

Public constructors

Builder

Added in 1.0.0
public Builder(@NonNull 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
public Builder(@NonNull IconCompat icon)

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
public Builder(@NonNull IconCompat icon, @NonNull CarIconStyle style)

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
@NonNull IconCompat icon

The base icon or image graphic.

@NonNull CarIconStyle style

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 methods

build

Added in 1.0.0
public @NonNull CarIcon build()

Constructs the CarIcon defined by this builder.

setStyle

Added in 1.9.0-alpha02
public @NonNull CarIcon.Builder setStyle(@NonNull CarIconStyle style)

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
@NonNull CarIconStyle style

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

setTint

Added in 1.0.0
Deprecated in 1.9.0-alpha02
public @NonNull CarIcon.Builder setTint(@NonNull CarColor tint)

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