Cómo agregar CarIcons intercalados para filas

Puedes agregar íconos intercalados con texto para enriquecer el atractivo visual de tu app con CarIconSpan. Consulta la documentación de CarIconSpan.create si deseas obtener más información para crear estos intervalos. Consulta Cómo usar intervalos para dar un estilo increíble al texto para ver una descripción general del funcionamiento de los estilos de texto con intervalos.

val rating = SpannableString("Rating: 4.5 stars")
rating.setSpan(
    CarIconSpan.create(
        // Create a CarIcon with an image of four and a half stars
        CarIcon.Builder(
            IconCompat.createWithResource(carContext, R.drawable.ic_star)
        ).build(),
        // Align the CarIcon to the baseline of the text
        CarIconSpan.ALIGN_BASELINE
    ),
    // The start index of the span (index of the character '4')
    8,
    // The end index of the span (exclusive, length of the string)
    17,
    Spanned.SPAN_INCLUSIVE_INCLUSIVE
)

val row = Row.Builder()
    .setTitle("Rating Row")
    .addText(rating)
    .build()