在android textview中显示富文本

时间:2017-03-13 12:01:22

标签: android

例如,这是我的富文本

{\ rtf1 \ fbidis \ ansi \ ansicpg1252 \ deff0 {\ fonttbl {\ f0 \ fswiss \ fprq2 \ fcharset0 Candara;} {\ f1 \ fnil \ fcharset0 Calibri;} {\ f2 \ fnil \ fcharset0 Candara;}} \ viewkind4 \ uc1 \ pard \ ltrpar \ lang1033 \ f0 \ fs24 \ f1 {\ pict \ wmetafile8 \ picw397 \ pich450 \ picwgoal225 \ pichgoal255的系数 0100090000037000000000004700000000000400000003010800050000000b0200000000050000 000c0212001000030000001e000400000007010400040000000701040047000000410b2000cc00 11000f000000000011000f0000000000280000000f000000110000000100010000000000000000 000000000000000000000000000000000000000000ffffff00fffe0101fffe0101fffe010111fe 0100bbfe0101d7fe0101effe0101d7fe0111bb02010111b60101ffb60101ff960100ff260001ff fe0001fffe0101fffe0100fffe0101040000002701ffff030000000000 } \ f0在扩展\ f1 {\ pict \ wmetafile8 \ picw3466 \ pich556 \ picwgoal1965 \ pichgoal315 010009000003200100000000f700000000000400000003010800050000000b0200000000050000 000c0216008400030000001e0004000000070104000400000007010400f7000000410b2000cc00 150083000000000015008300000000002800000083000000150000000100010000000000000000 000000000000000000000000000000000000000000ffffff00ffffffffffffffffffffffffffff ffffe0010101f3fffffffffffffffffffffffff9ffffe0010101efffffffffffffffffffffffff feffffe0010101dfffffffffffffffffffffffffff7fffe0010101dfffffffffffffffffffffff ffff7fffe0010101bf83ff7fc47fdff11fffefffffffbfffe0010101bfefff7feeffdffbbfffef ffffffbfffe0000101bfefff7ff5ffdffd7fffefffffffbfffe0010101bfefff7ffbffdffeffff efffffffbfffe0010101bfeff007f5fc01fd7ffe00fce73fbfffe0010101bfefff7feeffdffbb8 7feffce73fbfffe0010101bfefff7fc47fdff11b7fefffffffbfffe0010101dfafff7fffffdfff fdffefffffff7fffe0010101dfcfff7fffffdffffeffefffffff7fffe0010101efefffffffffff ffff7ffffffffefff800010101f3fffffffffffffffb7ffffffff9fffda0010101ffffffffffff fffffc7ffffffffffffda0010101fffffffffffffffffffffffffffff81ca0010101ffffffffff fffffffffffffffffffff920010101ffffffffffffffffffffffffffffffffe0010001ffffffff ffffffffffffffffffffffffe0010101040000002701ffff030000000000 } \ f0是\ f2 \ fs23 \ par }

我想在textview中显示富文本

1 个答案:

答案 0 :(得分:1)

试试这种方式

RTFEditorKit rtfParser = new RTFEditorKit();
Document document = rtfParser.createDefaultDocument();
rtfParser.read(new ByteArrayInputStream(rtfBytes), document, 0);
String text = document.getText(0, document.getLength());

归功于him