I am trying to batch-add several thousand spans to a SpannableStringBuilder
in an EditText
(obtained via getText()
).
This is slower than I would like. Profiling has shown that the vast majority of the time is being spent in DynamicLayout.reflow
. Is there a way to block the layout reflow until I am done adding spans?
To batch text reflow / layout changes use
AppCompatMultiAutoCompleteTextView
as your base class and surround the code you wish to batch withbeginBatchEdit()
andendBatchEdit()
i.e.
AppCompatMultiAutoCompleteTextView
usesSpannableBuilder
, a subclass ofSpannableStringBuilder
with batching support.