CarIconSpan ব্যবহার করে আপনার অ্যাপের ভিজ্যুয়াল আবেদন বৃদ্ধি করতে আপনি টেক্সটের সাথে ইনলাইন আইকন যোগ করতে পারেন। এই স্প্যানগুলি তৈরি করার বিষয়ে আরও তথ্যের জন্য CarIconSpan.create এর ডকুমেন্টেশন দেখুন। স্প্যানগুলি দিয়ে টেক্সট স্টাইলিং কীভাবে কাজ করে তার একটি সারসংক্ষেপের জন্য Spantastic টেক্সট স্টাইলিং with Spans দেখুন।
কোটলিন
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(...).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 (index of the last 's' in "stars")
16,
Spanned.SPAN_INCLUSIVE_INCLUSIVE
)
val row = Row.Builder()
...
.addText(rating)
.build()
জাভা
SpannableString rating = new SpannableString("Rating: 4.5 stars");
rating.setSpan(
CarIconSpan.create(
// Create a CarIcon with an image of four and a half stars
new CarIcon.Builder(...).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 (index of the last 's' in "stars")
16,
Spanned.SPAN_INCLUSIVE_INCLUSIVE
);
Row row = new Row.Builder()
...
.addText(rating)
.build();