How to display .rtf file inside TextView?

my application needs to display its own text stored in a bunch of .rtf files inside a TextView. I have searched in various forums, and I still do not have a clear solution. Seems pretty easy? I developed several applications like this in iOS, and I had no problem displaying .rtf text inside a UITextView as an attribute string. I thought Android would be easier. thank you for your time

+7
android text textview rtf
source share
1 answer

Seems pretty easy?

Not particularly. Hell, even Windows pretty much abandoned RTF ten years ago.

Option # 1: if you planned to pack RTF in the application itself (for example, as source resources or assets), get rid of RTF and first use HTML in your application using either Html.fromHtml() and a TextView or use WebView .

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

Option # 3: find the C / C ++ cross-architecture code that can convert RTF to HTML on the fly, add it to your application via the NDK, and then continue as in Option # 1.

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

+11
source share

All Articles