MeasuredText
public
class
MeasuredText
extends Object
| java.lang.Object | |
| ↳ | android.graphics.text.MeasuredText |
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();
Summary
Nested classes | |
|---|---|
class |
MeasuredText.Builder
Helper class for creating a |
Public methods | |
|---|---|
void
|
getBounds(int start, int end, Rect rect)
Retrieves the boundary box of the given range |
float
|
getCharWidthAt(int offset)
Returns the width of the character at the given offset. |
void
|
getFontMetricsInt(int start, int end, Paint.FontMetricsInt outMetrics)
Retrieves the font metrics of the given range |
float
|
getWidth(int start, int end)
Returns the width of a given range. |
Inherited methods | |
|---|---|
Public methods
getBounds
public void getBounds (int start,
int end,
Rect rect)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
public float getCharWidthAt (int offset)
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 |
| Returns | |
|---|---|
float |
Value is 0.0f or greater The units of this value are pixels. |
getFontMetricsInt
public void getFontMetricsInt (int start,
int end,
Paint.FontMetricsInt outMetrics)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
public float getWidth (int start,
int end)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 |
| Returns | |
|---|---|
float |
Value is 0.0f or greater The units of this value are pixels. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-10-15 UTC.