如何以html格式转换新的TypefaceSpan(" cursive")或自定义Typefacespan?

时间:2015-01-28 07:29:56

标签: android html font-face spannablestring android-typeface

我使用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);

0 个答案:

没有答案