I tried this:
String s = "Some big string"
SpannableStringBuilder sb = new SpannableStringBuilder(s);
//normal font for 1st 9 chars
sb.setSpan(robotoRegular, 0,9,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//bold font for rest of the chars
sb.setSpan(robotoBold, 9,s.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//also change color for rest of the chars
sb.setSpan(new ForegroundColorSpan(Color.BLACK), 9,s.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView.setText(sb);
But this didn’t work.
It only takes the latest setSpan, ie.., the Text color is being changed but not the font.
You have to use a
TypefaceSpaninstead of aTypeface.But since you are using a custom typeface you need to extend
TypefaceSpan.Check out this answer and create
CustomTypefaceSpanclass.Now do the following: