CarIcon
public
final
class
CarIcon
extends Object
java.lang.Object | |
↳ | androidx.car.app.model.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 pixel densities. To ensure that icons and images render well across all car screens, use vector assets whenever possible to avoid scaling issues. If you use a bitmap instead, ensure that you have resources that address multiple pixel density buckets.
In order to support all car screen sizes and pixel density, you can use configuration
qualifiers in your resource files (e.g. "mdpi", "hdpi", etc). See
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 classes | |
---|---|
class |
CarIcon.Builder
A builder of |
Constants | |
---|---|
int |
TYPE_ALERT
An alert icon. |
int |
TYPE_APP_ICON
The app's icon. |
int |
TYPE_BACK
An icon representing a "back" action. |
int |
TYPE_CUSTOM
A custom, non-standard, app-defined icon. |
int |
TYPE_ERROR
An error icon. |
Fields | |
---|---|
public
static
final
CarIcon |
ALERT
An icon representing an alert. |
public
static
final
CarIcon |
APP_ICON
Represents the app's icon, as defined in the app's manifest by the |
public
static
final
CarIcon |
BACK
An icon representing a "back" action. |
public
static
final
CarIcon |
ERROR
An icon representing an error. |
Public methods | |
---|---|
boolean
|
equals(Object other)
|
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()
|
Inherited methods | |
---|---|
Constants
TYPE_ALERT
public static final int TYPE_ALERT
An alert icon.
See also:
Constant Value: 4 (0x00000004)
TYPE_APP_ICON
public static final int TYPE_APP_ICON
The app's icon.
See also:
Constant Value: 5 (0x00000005)
TYPE_BACK
public static final int TYPE_BACK
An icon representing a "back" action.
See also:
Constant Value: 3 (0x00000003)
TYPE_CUSTOM
public static final int TYPE_CUSTOM
A custom, non-standard, app-defined icon.
Constant Value: 1 (0x00000001)
TYPE_ERROR
public static final int TYPE_ERROR
An error icon.
See also:
Constant Value: 6 (0x00000006)
Fields
APP_ICON
public static final CarIcon APP_ICON
Represents the app's icon, as defined in the app's manifest by the android:icon
attribute of the application
element.
Public methods
equals
public boolean equals (Object other)
Parameters | |
---|---|
other |
Object |
Returns | |
---|---|
boolean |
getIcon
public IconCompat getIcon ()
Returns the IconCompat
instance backing by this car icon or null
if one
isn't set.
Returns | |
---|---|
IconCompat |
See also:
getTint
public CarColor getTint ()
Returns the tint of the icon or null
if not set.
Returns | |
---|---|
CarColor |
See also:
getType
public int getType ()
Returns the type of car icon for this instance.
Returns | |
---|---|
int |
hashCode
public int hashCode ()
Returns | |
---|---|
int |
toString
public String toString ()
Returns | |
---|---|
String |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-24 UTC.