Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder#inhmethods)

# CursorAnchorInfo.Builder

*** ** * ** ***


`
public
static
final

class
CursorAnchorInfo.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.inputmethod.CursorAnchorInfo.Builder |

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo`. This class is not designed to be thread-safe.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder#Builder()() ` |

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

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(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` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

```
public Builder ()
```

<br />

<br />

## Public methods

### addCharacterBounds

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

```
public CursorAnchorInfo.Builder addCharacterBounds (int index, 
                float left, 
                float top, 
                float right, 
                float bottom, 
                int flags)
```

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

<br />

| Parameters ||
|---|---|
| `index` | `int`: index of the character in Java chars units. Must be specified in ascending order across successive calls. <br /> |
| `left` | `float`: x coordinate of the left edge of the character in local coordinates. <br /> |
| `top` | `float`: y coordinate of the top edge of the character in local coordinates. <br /> |
| `right` | `float`: x coordinate of the right edge of the character in local coordinates. <br /> |
| `bottom` | `float`: y coordinate of the bottom edge of the character in local coordinates. <br /> |
| `flags` | `int`: flags for this character bounds. See `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_VISIBLE_REGION`, `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_INVISIBLE_REGION` and `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#FLAG_IS_RTL`. These flags must be specified when necessary. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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#ApiLevels)

```
public CursorAnchorInfo.Builder addVisibleLineBounds (float left, 
                float top, 
                float right, 
                float bottom)
```

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.

<br />

| Parameters ||
|---|---|
| `left` | `float`: the left bound of the left-most character in the line <br /> |
| `top` | `float`: the top bound of the top-most character in the line <br /> |
| `right` | `float`: the right bound of the right-most character in the line <br /> |
| `bottom` | `float`: the bottom bound of the bottom-most character in the line <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getVisibleLineBounds()`
- `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder#clearVisibleLineBounds()`

### build

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

```
public CursorAnchorInfo build ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo` | `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo` using parameters in this `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if one or more positional parameters are specified but the coordinate transformation matrix is not provided via `https://developer.android.com/reference/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#ApiLevels)

```
public CursorAnchorInfo.Builder clearVisibleLineBounds ()
```

Clear the visible text line bounds previously added to this `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | This value cannot be `null`. <br /> |

**See also:**

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

### reset

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

```
public void reset ()
```

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

<br />

### setComposingText

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

```
public CursorAnchorInfo.Builder setComposingText (int composingTextStart, 
                CharSequence composingText)
```

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

<br />

| Parameters ||
|---|---|
| `composingTextStart` | `int`: index where the composing text starts. <br /> |
| `composingText` | `CharSequence`: the entire composing text. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | <br /> |

### setEditorBoundsInfo

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

```
public CursorAnchorInfo.Builder setEditorBoundsInfo (EditorBoundsInfo bounds)
```

Sets the current editor related bounds.

<br />

| Parameters ||
|---|---|
| `bounds` | `EditorBoundsInfo`: `https://developer.android.com/reference/android/view/inputmethod/EditorBoundsInfo` in local coordinates. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | This value cannot be `null`. <br /> |

### setInsertionMarkerLocation

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

```
public CursorAnchorInfo.Builder setInsertionMarkerLocation (float horizontalPosition, 
                float lineTop, 
                float lineBaseline, 
                float lineBottom, 
                int flags)
```

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.

<br />

| 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 `https://developer.android.com/reference/android/text/Layout#getPrimaryHorizontal(int)`. <br /> |
| `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 `https://developer.android.com/reference/android/text/Layout#getLineTop(int)`. <br /> |
| `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 `https://developer.android.com/reference/android/text/Layout#getLineBaseline(int)`. <br /> |
| `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 `https://developer.android.com/reference/android/text/Layout#getLineBottom(int)`. <br /> |
| `flags` | `int`: flags of the insertion marker. See `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#FLAG_HAS_VISIBLE_REGION` for example. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | <br /> |

### setMatrix

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

```
public CursorAnchorInfo.Builder setMatrix (Matrix matrix)
```

Sets the matrix that transforms local coordinates into screen coordinates.

<br />

| Parameters ||
|---|---|
| `matrix` | `Matrix`: transformation matrix from local coordinates into screen coordinates. null is interpreted as an identity matrix. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | <br /> |

### setSelectionRange

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

```
public CursorAnchorInfo.Builder setSelectionRange (int newStart, 
                int newEnd)
```

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

<br />

| Parameters ||
|---|---|
| `newStart` | `int` <br /> |
| `newEnd` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | <br /> |

### setTextAppearanceInfo

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

```
public CursorAnchorInfo.Builder setTextAppearanceInfo (TextAppearanceInfo textAppearanceInfo)
```

Set the information related to text appearance, which is extracted from the original
`https://developer.android.com/reference/android/widget/TextView`.

<br />

| Parameters ||
|---|---|
| `textAppearanceInfo` | `TextAppearanceInfo`: `https://developer.android.com/reference/android/view/inputmethod/TextAppearanceInfo` of TextView. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo.Builder` | This value cannot be `null`. <br /> |