当我使用 StaticLayout 创建大文本 (~6mb) 的分页时出现错误。这是我的日志:
java.lang.OutOfMemoryError
at android.text.MeasuredText.addStyleRun(MeasuredText.java:193)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:269)
at android.text.StaticLayout.generate(StaticLayout.java:291)
at android.text.StaticLayout.<init>(StaticLayout.java:143)
at android.text.StaticLayout.<init>(StaticLayout.java:93)
at android.text.StaticLayout.<init>(StaticLayout.java:71)
at android.text.StaticLayout.<init>(StaticLayout.java:51)
at com.ex.test.pagenation.Pagination.layout(Pagination.java:38)
at com.ex.test.pagenation.Pagination.<init>(Pagination.java:34)
at com.ex.test.pagenation.MainActivity$1.onGlobalLayout(MainActivity.java:51)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2006)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
有什么建议可以解决这个错误吗?或者有没有替代的解决方案?