CarIcon


@CarProtocol
class CarIcon


Represents an icon to be used in a car app.

Car icons wrap a backing IconCompat, and add additional attributes optimized for the car such as a CarColor tint.

Car Screen Pixel Densities

Similar to Android devices, car screens cover a wide range of sizes and densities. To ensure that icons and images render well across all car screens, use vector assets whenever possible to avoid scaling issues. If your app relies on bitmaps or other non-vector assets, you should ensure that you have resources that address multiple pixel density buckets using configuration qualifiers in your resource folders (e.g. "mdpi", "hdpi", etc). See androidx.car.app.CarContext for more details.

Themed Drawables Vector drawables can contain references to attributes declared in a theme. For example:
<vector ...
  <path
    android:pathData="..."
    android:fillColor="?myIconColor"/>
</vector>
The theme must be defined in the app's manifest metadata, by declaring them in a theme and referencing it from the androidx.car.app.theme metadata.

In AndroidManifest.xml, under the application element corresponding to the car app:

<meta-data
  android:name="androidx.car.app.theme"
  android:resource="@style/CarAppTheme"/>
The CarAppTheme style is defined as any other themes in a resource file:
<resources>
  <style name="CarAppTheme">
    <item name="myIconColor">@color/my_icon_color</item>
    ...
  </style>
</resources>

Summary

Nested types

A builder of CarIcon.

Constants

const CarIcon

An icon representing an alert.

const CarIcon

Represents the app's icon, as defined in the app's manifest by the android:icon attribute of the application element.

const CarIcon

An icon representing a "back" action.

const CarIcon

An icon that represents the user's intent to send a message.

const CarIcon

An icon representing an error.

const CarIcon
@RequiresCarApi(value = 2)
PAN

An icon representing a pan action (for example, in a map surface).

const Int

An alert icon.

const Int

The app's icon.

const Int

An icon representing a "back" action.

const Int

A message icon.

const Int

A custom, non-standard, app-defined icon.

const Int

An error icon.

const Int

A pan icon.

Public functions

Boolean
equals(other: Any?)
IconCompat?

Returns the IconCompat instance backing by this car icon or null if one isn't set.

CarColor?

Returns the tint of the icon or null if not set.

Int

Returns the type of car icon for this instance.

Int
String!

Constants

ALERT

Added in 1.0.0
const val ALERTCarIcon

An icon representing an alert.

APP_ICON

Added in 1.0.0
const val APP_ICONCarIcon

Represents the app's icon, as defined in the app's manifest by the android:icon attribute of the application element.

BACK

Added in 1.0.0
const val BACKCarIcon

An icon representing a "back" action.

COMPOSE_MESSAGE

Added in 1.4.0
@RequiresCarApi(value = 7)
const val COMPOSE_MESSAGECarIcon

An icon that represents the user's intent to send a message.

ERROR

Added in 1.0.0
const val ERRORCarIcon

An icon representing an error.

PAN

Added in 1.1.0
@RequiresCarApi(value = 2)
const val PANCarIcon

An icon representing a pan action (for example, in a map surface).

TYPE_ALERT

Added in 1.0.0
const val TYPE_ALERT = 4: Int

An alert icon.

See also
ALERT

TYPE_APP_ICON

Added in 1.0.0
const val TYPE_APP_ICON = 5: Int

The app's icon.

See also
APP_ICON

TYPE_BACK

Added in 1.0.0
const val TYPE_BACK = 3: Int

An icon representing a "back" action.

See also
BACK

TYPE_COMPOSE_MESSAGE

Added in 1.4.0
const val TYPE_COMPOSE_MESSAGE = 8: Int

A message icon.

See also
COMPOSE_MESSAGE

TYPE_CUSTOM

Added in 1.0.0
const val TYPE_CUSTOM = 1: Int

A custom, non-standard, app-defined icon.

TYPE_ERROR

Added in 1.0.0
const val TYPE_ERROR = 6: Int

An error icon.

See also
ERROR

TYPE_PAN

Added in 1.1.0
const val TYPE_PAN = 7: Int

A pan icon.

See also
PAN

Public functions

equals

fun equals(other: Any?): Boolean

getIcon

Added in 1.0.0
fun getIcon(): IconCompat?

Returns the IconCompat instance backing by this car icon or null if one isn't set.

See also
Builder

getTint

Added in 1.0.0
fun getTint(): CarColor?

Returns the tint of the icon or null if not set.

See also
setTint

getType

Added in 1.0.0
fun getType(): Int

Returns the type of car icon for this instance.

hashCode

fun hashCode(): Int

toString

fun toString(): String!