1.定义不同的style
<style name="approval_detail_info_style1"> <item name="android:textSize">@dimen/sp13</item> <item name="android:textColor">#666666</item> </style> <style name="approval_detail_info_style2"> <item name="android:textSize">@dimen/sp14</item> <item name="android:textColor">#333333</item> </style>
2.设置和使用style
SpannableString styledText = new SpannableString(string); styledText.setSpan(new TextAppearanceSpan(context, style1), 0, target, Spanned.SPAN_INCLUSIVE_INCLUSIVE); styledText.setSpan(new TextAppearanceSpan(context, style2), target+1, string.length()-1, Spanned.SPAN_INCLUSIVE_INCLUSIVE); return styledText;