Different car screen sizes may show different amounts of text. With Car App API
level 2 and later, you can specify multiple variants of a text string to best
fit the screen. To see where text variants are accepted, look for templates and
components that take a CarText.
You can add text string variants to a CarText with the
CarText.Builder.addVariant() method:
val itemTitle = CarText.Builder("This is a very long string") .addVariant("Shorter string") .build()
You can then use this CarText—for example, as the primary text of a
GridItem.
val gridItem = GridItem.Builder() .setTitle(itemTitle) .setImage(CarIcon.APP_ICON) .build()
Add strings in the order of from most to least preferred. For example, from longest to shortest. The host picks the appropriate-length string depending on the amount of space available on the car screen.