पंक्तियों के लिए इनलाइन कैरिकॉन जोड़ें

CarIconSpan का इस्तेमाल करके, अपने ऐप्लिकेशन को ज़्यादा आकर्षक बनाने के लिए, टेक्स्ट के साथ-साथ आइकॉन भी जोड़े जा सकते हैं. इन स्पैन को बनाने के बारे में ज़्यादा जानकारी के लिए, CarIconSpan.create का दस्तावेज़ देखें. स्पैन का इस्तेमाल करके टेक्स्ट को स्टाइल करने के तरीके के बारे में खास जानकारी पाने के लिए, स्पैन का इस्तेमाल करके टेक्स्ट को स्टाइल करना लेख पढ़ें.

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()