Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/graphics/text/MeasuredText#nestedclasses) \| [Methods](https://developer.android.com/reference/android/graphics/text/MeasuredText#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/text/MeasuredText#inhmethods)

# MeasuredText

*** ** * ** ***


`
public


class
MeasuredText
`


`

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


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.text.MeasuredText |

<br />

*** ** * ** ***

Result of text shaping of the single paragraph string.



    Paint paint = new Paint();
    Paint bigPaint = new Paint();
    bigPaint.setTextSize(paint.getTextSize() * 2.0);
    String text = "Hello, Android.";
    MeasuredText mt = new MeasuredText.Builder(text.toCharArray())
         .appendStyleRun(paint, 7, false)  // Use paint for "Hello, "
         .appendStyleRun(bigPaint, 8, false)  // Use bigPaint for "Android."
         .build();

<br />

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/graphics/text/MeasuredText.Builder` Helper class for creating a `https://developer.android.com/reference/android/graphics/text/MeasuredText`. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/graphics/text/MeasuredText#getBounds(int,%20int,%20android.graphics.Rect)(int start, int end, https://developer.android.com/reference/android/graphics/Rect rect) ` Retrieves the boundary box of the given range |
| ` float` | ` https://developer.android.com/reference/android/graphics/text/MeasuredText#getCharWidthAt(int)(int offset) ` Returns the width of the character at the given offset. |
| ` void` | ` https://developer.android.com/reference/android/graphics/text/MeasuredText#getFontMetricsInt(int,%20int,%20android.graphics.Paint.FontMetricsInt)(int start, int end, https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt outMetrics) ` Retrieves the font metrics of the given range |
| ` float` | ` https://developer.android.com/reference/android/graphics/text/MeasuredText#getWidth(int,%20int)(int start, int end) ` Returns the width of a given range. |

| ### 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 methods

### getBounds

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

```
public void getBounds (int start, 
                int end, 
                Rect rect)
```

Retrieves the boundary box of the given range

<br />

| Parameters ||
|---|---|
| `start` | `int`: an inclusive start index of the range. Value is 0 or greater <br /> |
| `end` | `int`: an exclusive end index of the range. Value is 0 or greater <br /> |
| `rect` | `Rect`: an output parameter. This value cannot be `null`. <br /> |

### getCharWidthAt

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

```
public float getCharWidthAt (int offset)
```

Returns the width of the character at the given offset.


The units of this value are pixels.

<br />

| Parameters ||
|---|---|
| `offset` | `int`: an offset of the character. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `float` | Value is 0.0f or greater. The units of this value are pixels. <br /> |

### getFontMetricsInt

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

```
public void getFontMetricsInt (int start, 
                int end, 
                Paint.FontMetricsInt outMetrics)
```

Retrieves the font metrics of the given range

<br />

| Parameters ||
|---|---|
| `start` | `int`: an inclusive start index of the range. Value is 0 or greater <br /> |
| `end` | `int`: an exclusive end index of the range. Value is 0 or greater <br /> |
| `outMetrics` | `Paint.FontMetricsInt`: an output metrics object. This value cannot be `null`. <br /> |

### getWidth

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

```
public float getWidth (int start, 
                int end)
```

Returns the width of a given range.


The units of this value are pixels.

<br />

| Parameters ||
|---|---|
| `start` | `int`: an inclusive start index of the range. Value is 0 or greater <br /> |
| `end` | `int`: an exclusive end index of the range. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `float` | Value is 0.0f or greater. The units of this value are pixels. <br /> |