1

I'm working on a Slice prototype, when looking at the Slice Templates page from Google I see examples like this very frequently

enter image description here

And it provides example code like

    list(context, sliceUri, ListBuilder.INFINITY) {
        setAccentColor(0xff0F9D) // Specify color for tinting icons
        header {
            title = "Get a ride"
            subtitle = "Ride in 4 min"
            summary = "Work in 1 hour 45 min | Home in 12 min"
        }
        row {
            title = "Home"
            subtitle = "12 miles | 12 min | $9.00"
            addEndItem(
                IconCompat.createWithResource(context, R.drawable.ic_home),
                ListBuilder.ICON_IMAGE
            )
        }
    }

However, I just don't see how the '4 min', '$31.41' or '$9.00' are suppose to be highlighted green, how is it out of those text string values, those specific parts are highlighted in the example?

P.s. this is prevalent on the whole page. Reference: https://developer.android.com/guide/slices/templates

cpb
  • 45
  • 2
  • 6
  • 1
    Google examples sometimes are a bit lacking from an end-to-end accuracy standpoint. If you create a `Spanned` object, such as via `SpannableStringBuilder`, and you format the text using standard spans (e.g., `ForegroundColorSpan`), that formatting should make it to the slice host. Assuming the slice host does not screw things up, your formatting should be applied. – CommonsWare Apr 21 '20 at 14:58
  • Thanks! I'll try that out and update the post if it works! – cpb Apr 21 '20 at 15:02

1 Answers1

0

As per CommonsWare comment above, the answer was to use a Spanned Object

cpb
  • 45
  • 2
  • 6