Added in API level 21

Builder


class Builder
kotlin.Any
   ↳ android.view.inputmethod.CursorAnchorInfo.Builder

Builder for CursorAnchorInfo. This class is not designed to be thread-safe.

Summary

Public constructors

Public methods
CursorAnchorInfo.Builder!
addCharacterBounds(index: Int, left: Float, top: Float, right: Float, bottom: Float, flags: Int)

Adds the bounding box of the character specified with the index.

CursorAnchorInfo.Builder
addVisibleLineBounds(left: Float, top: Float, right: Float, bottom: Float)

Add the bounds of a visible text line of the current editor.

CursorAnchorInfo!

CursorAnchorInfo.Builder

Clear the visible text line bounds previously added to this Builder.

Unit

Resets the internal state so that this instance can be reused to build another instance of CursorAnchorInfo.

CursorAnchorInfo.Builder!
setComposingText(composingTextStart: Int, composingText: CharSequence!)

Sets the text range of the composing text.

CursorAnchorInfo.Builder

Sets the current editor related bounds.

CursorAnchorInfo.Builder!
setInsertionMarkerLocation(horizontalPosition: Float, lineTop: Float, lineBaseline: Float, lineBottom: Float, flags: Int)

Sets the location of the text insertion point (zero width cursor) as a rectangle in local coordinates.

CursorAnchorInfo.Builder!
setMatrix(matrix: Matrix!)

Sets the matrix that transforms local coordinates into screen coordinates.

CursorAnchorInfo.Builder!
setSelectionRange(newStart: Int, newEnd: Int)

Sets the text range of the selection.

CursorAnchorInfo.Builder

Set the information related to text appearance, which is extracted from the original TextView.

Public constructors

Builder

Builder()

Public methods

addCharacterBounds

Added in API level 21
fun addCharacterBounds(
    index: Int,
    left: Float,
    top: Float,
    right: Float,
    bottom: Float,
    flags: Int
): CursorAnchorInfo.Builder!

Adds the bounding box of the character specified with the index.

Parameters
index Int: index of the character in Java chars units. Must be specified in ascending order across successive calls.
left Float: x coordinate of the left edge of the character in local coordinates.
top Float: y coordinate of the top edge of the character in local coordinates.
right Float: x coordinate of the right edge of the character in local coordinates.
bottom Float: y coordinate of the bottom edge of the character in local coordinates.
flags Int: flags for this character bounds. See FLAG_HAS_VISIBLE_REGION, FLAG_HAS_INVISIBLE_REGION and FLAG_IS_RTL. These flags must be specified when necessary.
Exceptions
java.lang.IllegalArgumentException If the index is a negative value, or not greater than all of the previously called indices.

addVisibleLineBounds

Added in API level 34
fun addVisibleLineBounds(
    left: Float,
    top: Float,
    right: Float,
    bottom: Float
): CursorAnchorInfo.Builder

Add the bounds of a visible text line of the current editor. The line bounds should not include the vertical space between lines or the horizontal space before and after a line. It's preferable if the line bounds are added in the logical order, so that IME can process them easily.

Parameters
left Float: the left bound of the left-most character in the line
top Float: the top bound of the top-most character in the line
right Float: the right bound of the right-most character in the line
bottom Float: the bottom bound of the bottom-most character in the line
Return
CursorAnchorInfo.Builder This value cannot be null.

build

Added in API level 21
fun build(): CursorAnchorInfo!
Return
CursorAnchorInfo! CursorAnchorInfo using parameters in this Builder.
Exceptions
java.lang.IllegalArgumentException if one or more positional parameters are specified but the coordinate transformation matrix is not provided via setMatrix(android.graphics.Matrix).

clearVisibleLineBounds

Added in API level 34
fun clearVisibleLineBounds(): CursorAnchorInfo.Builder

Clear the visible text line bounds previously added to this Builder.

Return
CursorAnchorInfo.Builder This value cannot be null.

reset

Added in API level 21
fun reset(): Unit

Resets the internal state so that this instance can be reused to build another instance of CursorAnchorInfo.

setComposingText

Added in API level 21
fun setComposingText(
    composingTextStart: Int,
    composingText: CharSequence!
): CursorAnchorInfo.Builder!

Sets the text range of the composing text. Calling this can be skipped if there is no composing text.

Parameters
composingTextStart Int: index where the composing text starts.
composingText CharSequence!: the entire composing text.

setEditorBoundsInfo

Added in API level 33
fun setEditorBoundsInfo(bounds: EditorBoundsInfo?): CursorAnchorInfo.Builder

Sets the current editor related bounds.

Parameters
bounds EditorBoundsInfo?: EditorBoundsInfo in local coordinates. This value may be null.
Return
CursorAnchorInfo.Builder This value cannot be null.

setInsertionMarkerLocation

Added in API level 21
fun setInsertionMarkerLocation(
    horizontalPosition: Float,
    lineTop: Float,
    lineBaseline: Float,
    lineBottom: Float,
    flags: Int
): CursorAnchorInfo.Builder!

Sets the location of the text insertion point (zero width cursor) as a rectangle in local coordinates. Calling this can be skipped when there is no text insertion point; however if there is an insertion point, editors must call this method.

Parameters
horizontalPosition Float: horizontal position of the insertion marker, in the local coordinates that will be transformed with the transformation matrix when rendered on the screen. This should be calculated or compatible with Layout#getPrimaryHorizontal(int).
lineTop Float: vertical position of the insertion marker, in the local coordinates that will be transformed with the transformation matrix when rendered on the screen. This should be calculated or compatible with Layout#getLineTop(int).
lineBaseline Float: vertical position of the insertion marker, in the local coordinates that will be transformed with the transformation matrix when rendered on the screen. This should be calculated or compatible with Layout#getLineBaseline(int).
lineBottom Float: vertical position of the insertion marker, in the local coordinates that will be transformed with the transformation matrix when rendered on the screen. This should be calculated or compatible with Layout#getLineBottom(int).
flags Int: flags of the insertion marker. See FLAG_HAS_VISIBLE_REGION for example.

setMatrix

Added in API level 21
fun setMatrix(matrix: Matrix!): CursorAnchorInfo.Builder!

Sets the matrix that transforms local coordinates into screen coordinates.

Parameters
matrix Matrix!: transformation matrix from local coordinates into screen coordinates. null is interpreted as an identity matrix.

setSelectionRange

Added in API level 21
fun setSelectionRange(
    newStart: Int,
    newEnd: Int
): CursorAnchorInfo.Builder!

Sets the text range of the selection. Calling this can be skipped if there is no selection.

setTextAppearanceInfo

Added in API level 34
fun setTextAppearanceInfo(textAppearanceInfo: TextAppearanceInfo?): CursorAnchorInfo.Builder

Set the information related to text appearance, which is extracted from the original TextView.

Parameters
textAppearanceInfo TextAppearanceInfo?: TextAppearanceInfo of TextView. This value may be null.
Return
CursorAnchorInfo.Builder This value cannot be null.