The problem is that you're trying to lay out the whole thing at once. Laying out 16,000 lines of text is expensive. It's going to take a nontrivial amount of time even on a desktop computer with a powerful CPU, and you're trying to do it on a phone.
Instead, take a progressive approach. Take an approximation of the amount of text you expect might fit in one page - maybe 1000 characters. You can tweak this value. Lay that out, see if it's enough, then lay out more if needed.
You can use DynamicLayout
to do this efficiently. Make sure to pass it an Editable
when creating it to allow you to update the layout as you add more text.