toBackgroundColorSpan

fun CharSequence.toBackgroundColorSpan(range: IntRange = IntRange(0, length), color: Int = Color.RED): SpannableString

Change the background color of the text specified in a paragraph of text

Parameters

range

The range of text to change the background color

color

The color to change, the default is red