PrecomputedTextCompat
open class PrecomputedTextCompat : Spannable
kotlin.Any | |
↳ | 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 android.widget.TextView
or StaticLayout
. Since the text layout information will be included in this instance, android.widget.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 android.text.NoCopySpan
attached to the original text won't be passed to PrecomputedText.
Summary
Nested classes | |
---|---|
The information required for building |
Public methods | |
---|---|
open static PrecomputedTextCompat! |
create(@NonNull text: CharSequence, @NonNull params: PrecomputedTextCompat.Params) Create a new |
open Char | |
open Int |
Returns the count of paragraphs. |
open Int |
getParagraphEnd(@IntRange(0) paraIndex: Int) Returns the paragraph end offset of the text. |
open Int |
getParagraphStart(@IntRange(0) paraIndex: Int) Returns the paragraph start offset of the text. |
open PrecomputedTextCompat.Params |
Returns the parameters used to measure this text. |
open Int |
getSpanEnd(tag: Any!) |
open Int |
getSpanFlags(tag: Any!) |
open Int |
getSpanStart(tag: Any!) |
open Array<T>! | |
open static Future<PrecomputedTextCompat!>! |
getTextFuture(@NonNull charSequence: CharSequence, @NonNull params: PrecomputedTextCompat.Params, @Nullable executor: Executor?) Helper for PrecomputedText that returns a future to be used with |
open Int |
nextSpanTransition(start: Int, limit: Int, type: Class<Any!>!) |
open Unit |
removeSpan(what: Any!) |
open Unit | |
open CharSequence |
subSequence(startIndex: Int, endIndex: Int) |
open String |
toString() |
Properties | |
---|---|
open Int |
Public methods
create
open static fun create(
@NonNull text: CharSequence,
@NonNull params: PrecomputedTextCompat.Params
): PrecomputedTextCompat!
Create a new PrecomputedText
which will pre-compute text measurement and glyph positioning information.
This can be expensive, so computing this on a background thread before your text will be presented can save work on the UI thread.
Note that anyandroid.text.NoCopySpan
attached to the text won't be passed to the created PrecomputedText.
Parameters | |
---|---|
text |
CharSequence: the text to be measured |
params |
PrecomputedTextCompat.Params: parameters that define how text will be precomputed |
Return | |
---|---|
PrecomputedTextCompat! |
A PrecomputedText |