How to display .rtf file inside TextView?

笑着哭i 提交于 2019-12-05 01:28:41

It seems pretty easy right?

Not especially. Heck, even Windows largely abandoned RTF a decade or so ago.

Option #1: If you were planning on packaging the RTF in the app itself (e.g., as raw resources or assets), get rid of the RTF and use HTML in your app in the first place, using either Html.fromHtml() and a TextView or use a WebView.

Option #2: Find some Java code that can convert RTF to HTML on the fly, then proceed as in Option #1.

Option #3: Find some cross-architecture C/C++ code that can convert RTF to HTML on the fly, add that to your app via the NDK, then proceed as in Option #1.

Option #4: Roll your own RTF parser and a SpannableStringBuilder to create the formatted Spannable to load into the TextView.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!