我使用SpannableStringBuilder将字符串数据转换为spannable字符串,然后使用Html.toHtml(spannable)将其转换为html格式。
现在我的问题是,我无法将我的TypefaceSpan或自定义TypefaceSpan转换为html格式,如**<p> <font face="cursive">This is some text!</font> </p>**
spannableString = new SpannableStringBuilder(customTxtEditor.getText());
Typeface font = Typeface.createFromAsset(context.getAssets(), fonts/arial.ttf");
spannableString.setSpan(new TypefaceSpan(font.toString()), startSelection, endSelection, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
或
spannableString.setSpan(font.getStyle(), startSelection, endSelection, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);