public class PrecomputedTextCompat
extends Object implements Spannable

   ↳ androidx.core.text.PrecomputedTextCompat

A text which has the character metrics data. A text object that contains the character metrics data and can be used to improve the performance of text layout operations. When a PrecomputedTextCompat is created with a given CharSequence, it will measure the text metrics during the creation. This PrecomputedText instance can be set on TextView or StaticLayout. Since the text layout information will be included in this instance, TextView or StaticLayout will not have to recalculate this information. On API 29 or later, there is full PrecomputedText support by framework. From API 21 to API 27, PrecomputedTextCompat relies on internal text layout cache. PrecomputedTextCompat immediately computes the text layout in the constuctor to warm up the internal text layout cache. On API 20 or before, PrecomputedTextCompat does nothing. Note that any NoCopySpan attached to the original text won't be passed to PrecomputedText.


Nested classes

class PrecomputedTextCompat.Params

The information required for building PrecomputedTextCompat

Inherited constants

Public methods

char charAt(int index)
static PrecomputedTextCompat create(CharSequence text, PrecomputedTextCompat.Params params)

Create a new PrecomputedText which will pre-compute text measurement and glyph positioning information.

int getParagraphCount()

Returns the count of paragraphs.

int getParagraphEnd(int paraIndex)

Returns the paragraph end offset of the text.

int getParagraphStart(int paraIndex)

Returns the paragraph start offset of the text.

PrecomputedTextCompat.Params getParams()

Returns the parameters used to measure this text.

int getSpanEnd(Object tag)
int getSpanFlags(Object tag)
int getSpanStart(Object tag)
<T> T[] getSpans(int start, int end, Class<T> type)
static Future<PrecomputedTextCompat> getTextFuture(CharSequence charSequence, PrecomputedTextCompat.Params params, Executor executor)

Helper for PrecomputedText that returns a future to be used with AppCompatTextView.setTextFuture(Future).

int length()
int nextSpanTransition(int start, int limit, Class type)
void removeSpan(Object what)
void setSpan(Object what, int start, int end, int flags)
CharSequence subSequence(int start, int end)
String toString()

Inherited methods