Added in API level 29

Standard


open class Standard : LineBackgroundSpan, ParcelableSpan
kotlin.Any
   ↳ android.text.style.LineBackgroundSpan.Standard

Default implementation of the LineBackgroundSpan, which changes the background color of the lines to which the span is attached.

For example, an LineBackgroundSpan can be used like this:

String text = "This is a multiline text. LineBackgroundSpan is applied here. This is a multiline text.";
  SpannableString string = new SpannableString(text);
  string.setSpan(new LineBackgroundSpan.Standard(Color.YELLOW), 26, 61, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  
Text with LineBackgroundSpan

Summary

Public constructors
Standard(color: Int)

Constructor taking a color integer.

Creates a LineBackgroundSpan.Standard from a parcel

Public methods
open Int

open Unit
drawBackground(canvas: Canvas, paint: Paint, left: Int, right: Int, top: Int, baseline: Int, bottom: Int, text: CharSequence, start: Int, end: Int, lineNumber: Int)

Draw the background on the canvas.

Int

open Int

open Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Public constructors

Standard

Added in API level 29
Standard(color: Int)

Constructor taking a color integer.

Parameters
color Int: Color integer that defines the background color.

Standard

Added in API level 29
Standard(src: Parcel)

Creates a LineBackgroundSpan.Standard from a parcel

Parameters
src Parcel: This value cannot be null.

Public methods

describeContents

Added in API level 29
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

drawBackground

Added in API level 29
open fun drawBackground(
    canvas: Canvas,
    paint: Paint,
    left: Int,
    right: Int,
    top: Int,
    baseline: Int,
    bottom: Int,
    text: CharSequence,
    start: Int,
    end: Int,
    lineNumber: Int
): Unit

Draw the background on the canvas.

Parameters
canvas Canvas: This value cannot be null.
paint Paint: This value cannot be null.
left Int: The units of this value are pixels.
right Int: The units of this value are pixels.
top Int: The units of this value are pixels.
baseline Int: The units of this value are pixels.
bottom Int: The units of this value are pixels.
text CharSequence: This value cannot be null.
start Int: start character index of the line
end Int: end character index of the line
lineNumber Int: line number in the current text layout

getColor

Added in API level 29
fun getColor(): Int
Return
Int the color of this span.

getSpanTypeId

Added in API level 29
open fun getSpanTypeId(): Int

writeToParcel

Added in API level 29
open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES