# CursorAnchorInfo.Builder

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                         ||
| ↳ | [android.view.inputmethod.CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#) |

Builder for[CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo). This class is not designed to be thread-safe.

## Summary

|                                                         Public constructors                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)! | [addCharacterBounds](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#addCharacterBounds(kotlin.Int,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `left:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `top:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `right:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `bottom:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Adds the bounding box of the character specified with the index. |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)  | [addVisibleLineBounds](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#addVisibleLineBounds(kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float))`(`left:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `top:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `right:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `bottom:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Add the bounds of a visible text line of the current editor.                                                                                                                                                                                                           |
| [CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo)!                  | [build](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#build())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)  | [clearVisibleLineBounds](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#clearVisibleLineBounds())`()` Clear the visible text line bounds previously added to this[Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                   | [reset](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#reset())`()` Resets the internal state so that this instance can be reused to build another instance of[CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)! | [setComposingText](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setComposingText(kotlin.Int,%20kotlin.CharSequence))`(`composingTextStart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `composingText:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Sets the text range of the composing text.                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)  | [setEditorBoundsInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setEditorBoundsInfo(android.view.inputmethod.EditorBoundsInfo))`(`bounds:` `[EditorBoundsInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/EditorBoundsInfo)?`)` Sets the current editor related bounds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)! | [setInsertionMarkerLocation](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setInsertionMarkerLocation(kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Int))`(`horizontalPosition:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `lineTop:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `lineBaseline:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `lineBottom:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the location of the text insertion point (zero width cursor) as a rectangle in local coordinates.                   |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)! | [setMatrix](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setMatrix(android.graphics.Matrix))`(`matrix:` `[Matrix](https://developer.android.com/reference/kotlin/android/graphics/Matrix.html#)!`)` Sets the matrix that transforms local coordinates into screen coordinates.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)! | [setSelectionRange](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setSelectionRange(kotlin.Int,%20kotlin.Int))`(`newStart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `newEnd:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the text range of the selection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#)  | [setTextAppearanceInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setTextAppearanceInfo(android.view.inputmethod.TextAppearanceInfo))`(`textAppearanceInfo:` `[TextAppearanceInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/TextAppearanceInfo)?`)` Set the information related to text appearance, which is extracted from the original[TextView](https://developer.android.com/reference/kotlin/android/widget/TextView.html#).                                                                                                                                                                                                                                                                                                                                        |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### addCharacterBounds

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):index of the character in Java chars units. Must be specified in ascending order across successive calls.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `left`   | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):x coordinate of the left edge of the character in local coordinates.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `top`    | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):y coordinate of the top edge of the character in local coordinates.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `right`  | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):x coordinate of the right edge of the character in local coordinates.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `bottom` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):y coordinate of the bottom edge of the character in local coordinates.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `flags`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):flags for this character bounds. See[FLAG_HAS_VISIBLE_REGION](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_VISIBLE_REGION:kotlin.Int),[FLAG_HAS_INVISIBLE_REGION](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_INVISIBLE_REGION:kotlin.Int)and[FLAG_IS_RTL](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo#FLAG_IS_RTL:kotlin.Int). 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):the left bound of the left-most character in the line     |
| `top`    | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):the top bound of the top-most character in the line       |
| `right`  | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):the right bound of the right-most character in the line   |
| `bottom` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):the bottom bound of the bottom-most character in the line |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#) | This value cannot be`null`. |

**See Also**

- [android.view.inputmethod.CursorAnchorInfo#getVisibleLineBounds()](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo#getVisibleLineBounds())
- <https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#clearVisibleLineBounds()>  

### build

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): CursorAnchorInfo!
```

|                                                                                                                                                                              Return                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo)! | [CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo)using parameters in this[Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.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)](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#setMatrix(android.graphics.Matrix)). |

### clearVisibleLineBounds

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun clearVisibleLineBounds(): CursorAnchorInfo.Builder
```

Clear the visible text line bounds previously added to this[Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#).

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#) | This value cannot be`null`. |

**See Also**

- [#addVisibleLineBounds(float, float, float, float)](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#addVisibleLineBounds(kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float))  

### reset

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun reset(): Unit
```

Resets the internal state so that this instance can be reused to build another instance of[CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo).  

### setComposingText

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):index where the composing text starts.         |
| `composingText`      | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!:the entire composing text. |

### setEditorBoundsInfo

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setEditorBoundsInfo(bounds: EditorBoundsInfo?): CursorAnchorInfo.Builder
```

Sets the current editor related bounds.

|                                                                                                                                     Parameters                                                                                                                                     ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bounds` | [EditorBoundsInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/EditorBoundsInfo)?:[EditorBoundsInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/EditorBoundsInfo)in local coordinates. This value may be`null`. |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#) | This value cannot be`null`. |

### setInsertionMarkerLocation

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):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)](https://developer.android.com/reference/kotlin/android/text/Layout.html#getPrimaryHorizontal(kotlin.Int)). |
| `lineTop`            | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):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)](https://developer.android.com/reference/kotlin/android/text/Layout.html#getLineTop(kotlin.Int)).                       |
| `lineBaseline`       | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):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)](https://developer.android.com/reference/kotlin/android/text/Layout.html#getLineBaseline(kotlin.Int)).             |
| `lineBottom`         | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):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)](https://developer.android.com/reference/kotlin/android/text/Layout.html#getLineBottom(kotlin.Int)).                 |
| `flags`              | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):flags of the insertion marker. See[FLAG_HAS_VISIBLE_REGION](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_VISIBLE_REGION:kotlin.Int)for example.                                                                                                                                                     |

### setMatrix

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setMatrix(matrix: Matrix!): CursorAnchorInfo.Builder!
```

Sets the matrix that transforms local coordinates into screen coordinates.

|                                                                                                     Parameters                                                                                                     ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `matrix` | [Matrix](https://developer.android.com/reference/kotlin/android/graphics/Matrix.html#)!:transformation matrix from local coordinates into screen coordinates. null is interpreted as an identity matrix. |

### setSelectionRange

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setTextAppearanceInfo(textAppearanceInfo: TextAppearanceInfo?): CursorAnchorInfo.Builder
```

Set the information related to text appearance, which is extracted from the original[TextView](https://developer.android.com/reference/kotlin/android/widget/TextView.html#).

|                                                                                                                                          Parameters                                                                                                                                           ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textAppearanceInfo` | [TextAppearanceInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/TextAppearanceInfo)?:[TextAppearanceInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/TextAppearanceInfo)of TextView. This value may be`null`. |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [CursorAnchorInfo.Builder](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.Builder#) | This value cannot be`null`. |