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
AppCompatMultiAutoCompleteTextViewas your base class and surround the code you wish to batch withbeginBatchEdit()andendBatchEdit()i.e.
AppCompatMultiAutoCompleteTextViewusesSpannableBuilder, a subclass ofSpannableStringBuilderwith batching support.