一、定义俩个不同的样式
<style name="business_price_text_gray"> <item name="android:textSize">@dimen/x28</item> <item name="android:textColor">@color/c_666666</item> </style> <style name="business_price_text_orange"> <item name="android:textSize">@dimen/x32</item> <item name="android:textColor">#ff4000</item> </style>
二、设置文字
SpannableString styledText = new SpannableString(goodsprice); styledText.setSpan(new TextAppearanceSpan(mContext, R.style.business_price_text_orange), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); styledText.setSpan(new TextAppearanceSpan(mContext, R.style.business_price_text_gray), length-3, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv_price.setText(styledText, TextView.BufferType.SPANNABLE);