Highlights.Builder


public static final class Highlights.Builder
extends Object

java.lang.Object
   ↳ android.text.Highlights.Builder


A builder for the Highlights.

Summary

Public constructors

Builder()

Public methods

Highlights.Builder addRange(Paint paint, int start, int end)

Add single range highlight.

Highlights.Builder addRanges(Paint paint, int... ranges)

Add multiple ranges highlight.

Highlights build()

Build a new Highlights instance.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

public Builder ()

Public methods

addRange

Added in API level 34
public Highlights.Builder addRange (Paint paint, 
                int start, 
                int end)

Add single range highlight. The TextView and underlying Layout draws highlight in the order of the addRange(Paint, int, int) calls. For example, the following code draws (1, 2) with red and (2, 5) with blue. val redPaint = Paint().apply { color = Color.RED } val bluePaint = Paint().apply { color = Color.BLUE } val highlight = Highlights.Builder() .addRange(redPaint, 1, 4) .addRange(bluePaint, 2, 5) .build()

Parameters
paint Paint: a paint object used for drawing highlight path.

start int: an inclusive offset of the text.

end int: an exclusive offset of the text.

Returns
Highlights.Builder this builder instance.

addRanges

Added in API level 34
public Highlights.Builder addRanges (Paint paint, 
                int... ranges)

Add multiple ranges highlight. For example, the following code draws (1, 2) with red and (2, 5) with blue. val redPaint = Paint().apply { color = Color.RED } val bluePaint = Paint().apply { color = Color.BLUE } val highlight = Highlights.Builder() .addRange(redPaint, 1, 4) .addRange(bluePaint, 2, 5) .build()

Parameters
paint Paint: a paint object used for drawing highlight path.

ranges int: a flatten ranges. The 2 * i-th element is an inclusive start offset of the i-th character. The 2 * i + 1-th element is an exclusive end offset of the i-th character.

Returns
Highlights.Builder this builder instance.

build

Added in API level 34
public Highlights build ()

Build a new Highlights instance.

Returns
Highlights a new Highlights instance.