CarIcon
@CarProtocol
public final 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>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 |
|---|
public final class CarIcon.BuilderA builder of |
Constants |
|
|---|---|
static final @NonNull CarIcon |
An icon representing an alert. |
static final @NonNull CarIcon |
Represents the app's icon, as defined in the app's manifest by the |
static final @NonNull CarIcon |
An icon representing a "back" action. |
static final @NonNull CarIcon |
@RequiresCarApi(value = 7)An icon that represents the user's intent to send a message. |
static final @NonNull CarIcon |
An icon representing an error. |
static final @NonNull CarIcon |
@RequiresCarApi(value = 8)An icon that represents a playable media item. |
static final @NonNull CarIcon |
@RequiresCarApi(value = 2)An icon representing a pan action (for example, in a map surface). |
static final int |
TYPE_ALERT = 4An alert icon. |
static final int |
TYPE_APP_ICON = 5The app's icon. |
static final int |
TYPE_BACK = 3An icon representing a "back" action. |
static final int |
A message icon. |
static final int |
TYPE_CUSTOM = 1A custom, non-standard, app-defined icon. |
static final int |
TYPE_ERROR = 6An error icon. |
static final int |
A media playback icon. |
static final int |
TYPE_PAN = 7A pan icon. |
Public methods |
|
|---|---|
boolean |
|
@Nullable IconCompat |
getIcon()Returns the |
@Nullable 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
public static final @NonNull CarIcon APP_ICON
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)
public static final @NonNull CarIcon COMPOSE_MESSAGE
An icon that represents the user's intent to send a message.
MEDIA_PLAYBACK
@RequiresCarApi(value = 8)
public static final @NonNull CarIcon MEDIA_PLAYBACK
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)
public static final @NonNull CarIcon PAN
An icon representing a pan action (for example, in a map surface).
TYPE_APP_ICON
public static final int TYPE_APP_ICON = 5
The app's icon.
| See also | |
|---|---|
APP_ICON |
TYPE_BACK
public static final int TYPE_BACK = 3
An icon representing a "back" action.
| See also | |
|---|---|
BACK |
TYPE_COMPOSE_MESSAGE
public static final int TYPE_COMPOSE_MESSAGE = 8
A message icon.
| See also | |
|---|---|
COMPOSE_MESSAGE |
TYPE_CUSTOM
public static final int TYPE_CUSTOM = 1
A custom, non-standard, app-defined icon.
TYPE_MEDIA_PLAYBACK
public static final int TYPE_MEDIA_PLAYBACK = 9
A media playback icon.
| See also | |
|---|---|
MEDIA_PLAYBACK |
Public methods
getIcon
public @Nullable IconCompat getIcon()
Returns the IconCompat instance backing by this car icon or null if one isn't set.
| See also | |
|---|---|
Builder |