SpannableString

多种样式设置
在这里插入图片描述

  SpannableString spannableString =new SpannableString(((TextView)helper.getView(R.id.txt_goods)).getText().toString());
     ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#ffa842"));
     spannableString.setSpan(colorSpan, 0, 2, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
     ForegroundColorSpan colorSpan1 = new ForegroundColorSpan(Color.parseColor("#999999"));
     spannableString.setSpan(colorSpan1, 3, 4, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
     spannableString.setSpan(  new RelativeSizeSpan(0.8f),3,4,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

     ((TextView)helper.getView(R.id.txt_goods)).setText(spannableString);
     

了解更多SpannableString知识,可查看以下文档:
设置不同字体 顶部对其显示
设置不同字体 居中显示
https://blog.csdn.net/android157/article/details/90762135
https://blog.csdn.net/jdsjlzx/article/details/19122103
https://blog.csdn.net/zuo_er_lyf/article/details/80340819
https://blog.csdn.net/lukejunandroid/article/details/25892737

你可能感兴趣的:(andorid,SpannableString,TextView,多种字体颜色样式)