Added in API level 29

MeasuredText


open class MeasuredText
kotlin.Any
   ↳ android.graphics.text.MeasuredText

Result of text shaping of the single paragraph string.

<code>  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();  </code>

Summary

Nested classes

Helper class for creating a MeasuredText.

Public methods
open Unit
getBounds(start: Int, end: Int, rect: Rect)

Retrieves the boundary box of the given range

open Float

Returns the width of the character at the given offset.

open Unit
getFontMetricsInt(start: Int, end: Int, outMetrics: Paint.FontMetricsInt)

Retrieves the font metrics of the given range

open Float
getWidth(start: Int, end: Int)

Returns the width of a given range.

Public methods

getBounds

Added in API level 29
open fun getBounds(
    start: Int,
    end: Int,
    rect: Rect
): Unit

Retrieves the boundary box of the given range

Parameters
start Int: an inclusive start index of the range Value is 0 or greater
end Int: an exclusive end index of the range Value is 0 or greater
rect Rect: an output parameter This value cannot be null.

getCharWidthAt

Added in API level 29
open fun getCharWidthAt(offset: Int): Float

Returns the width of the character at the given offset.
The units of this value are pixels.

Parameters
offset Int: an offset of the character. Value is 0 or greater
Return
Float Value is 0.0f or greater The units of this value are pixels. {}

getFontMetricsInt

Added in API level 33
open fun getFontMetricsInt(
    start: Int,
    end: Int,
    outMetrics: Paint.FontMetricsInt
): Unit

Retrieves the font metrics of the given range

Parameters
start Int: an inclusive start index of the range Value is 0 or greater
end Int: an exclusive end index of the range Value is 0 or greater
outMetrics Paint.FontMetricsInt: an output metrics object This value cannot be null.

getWidth

Added in API level 29
open fun getWidth(
    start: Int,
    end: Int
): Float

Returns the width of a given range.
The units of this value are pixels.

Parameters
start Int: an inclusive start index of the range Value is 0 or greater
end Int: an exclusive end index of the range Value is 0 or greater
Return
Float Value is 0.0f or greater The units of this value are pixels. {}