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.
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.
<vector ... <path android:pathData="..." android:fillColor="?myIconColor"/> </vector>
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"/>
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 |
|---|
class CarIcon.BuilderA builder of |
Constants |
|
|---|---|
const CarIcon |
An icon representing an alert. |
const CarIcon |
Represents the app's icon, as defined in the app's manifest by the |
const CarIcon |
An icon representing a "back" action. |
const CarIcon |
@RequiresCarApi(value = 7)An icon that represents the user's intent to send a message. |
const CarIcon |
An icon representing an error. |
const CarIcon |
@RequiresCarApi(value = 8)An icon that represents a playable media item. |
const CarIcon |
@RequiresCarApi(value = 2)An icon representing a pan action (for example, in a map surface). |
const Int |
TYPE_ALERT = 4An alert icon. |
const Int |
TYPE_APP_ICON = 5The app's icon. |
const Int |
TYPE_BACK = 3An icon representing a "back" action. |
const Int |
A message icon. |
const Int |
TYPE_CUSTOM = 1A custom, non-standard, app-defined icon. |
const Int |
TYPE_ERROR = 6An error icon. |
const Int |
A media playback icon. |
const Int |
TYPE_PAN = 7A pan icon. |
Public functions |
|
|---|---|
Boolean |
|
IconCompat? |
getIcon()Returns the |
CarColor? |
getTint()Returns the tint of the icon or |
Int |
getType()Returns the type of car icon for this instance. |
Int |
hashCode() |
String! |
toString() |
Constants
APP_ICON
const val APP_ICON: CarIcon
Represents the app's icon, as defined in the app's manifest by the android:icon attribute of the application element.
COMPOSE_MESSAGE
@RequiresCarApi(value = 7)
const val COMPOSE_MESSAGE: CarIcon
An icon that represents the user's intent to send a message.
MEDIA_PLAYBACK
@RequiresCarApi(value = 8)
const val MEDIA_PLAYBACK: CarIcon
An icon that represents a playable media item. Note: This is specifically used for category MEDIA apps. Used in conjunction with Action.MEDIA_PLAYBACK
PAN
@RequiresCarApi(value = 2)
const val PAN: CarIcon
An icon representing a pan action (for example, in a map surface).
TYPE_BACK
const val TYPE_BACK = 3: Int
An icon representing a "back" action.
| See also | |
|---|---|
BACK |
TYPE_COMPOSE_MESSAGE
const val TYPE_COMPOSE_MESSAGE = 8: Int
A message icon.
| See also | |
|---|---|
COMPOSE_MESSAGE |
TYPE_MEDIA_PLAYBACK
const val TYPE_MEDIA_PLAYBACK = 9: Int
A media playback icon.
| See also | |
|---|---|
MEDIA_PLAYBACK |
Public functions
getIcon
fun getIcon(): IconCompat?
Returns the IconCompat instance backing by this car icon or null if one isn't set.
| See also | |
|---|---|
Builder |