{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

TextRangeKt

public final class TextRangeKt


Summary

Public methods

static final @NonNull TextRange
TextRange(int index)

Creates a TextRange where start is equal to end, and the value of those are index.

static final @NonNull TextRange
TextRange(int start, int end)

An immutable text range class, represents a text range from start (inclusive) to end (exclusive).

static final @NonNull TextRange
coerceIn(@NonNull TextRange receiver, int minimumValue, int maximumValue)

Ensures that TextRange.start and TextRange.end values lies in the specified range minimumValue and maximumValue.

static final @NonNull String

Public methods

TextRange

public static final @NonNull TextRange TextRange(int index)

Creates a TextRange where start is equal to end, and the value of those are index.

TextRange

public static final @NonNull TextRange TextRange(int start, int end)

An immutable text range class, represents a text range from start (inclusive) to end (exclusive). end can be smaller than start and in those cases min and max can be used in order to fetch the values.

Parameters
int start

the inclusive start offset of the range. Must be non-negative, otherwise an exception will be thrown.

int end

the exclusive end offset of the range. Must be non-negative, otherwise an exception will be thrown.

coerceIn

public static final @NonNull TextRange coerceIn(@NonNull TextRange receiver, int minimumValue, int maximumValue)

Ensures that TextRange.start and TextRange.end values lies in the specified range minimumValue and maximumValue. For each TextRange.start and TextRange.end values:

Parameters
int minimumValue

the minimum value that TextRange.start or TextRange.end can be.

int maximumValue

the exclusive maximum value that TextRange.start or TextRange.end can be.

substring

public static final @NonNull String substring(@NonNull CharSequence receiver, @NonNull TextRange range)