0

I'm using SpannableStringBuilder to set a string partially with a style of bold, however it's not working and I am unsure of what I am doing incorrectly.

String normalText = "New Here? ";
String boldText = "Register";
        
SpannableStringBuilder str = new SpannableStringBuilder(normalText + boldText);
tr.setSpan(new StyleSpan(Typeface.BOLD), normalText.length(), str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mBtnRegister.setText(str);

I've followed this SO example:

https://stackoverflow.com/a/41460376/11110509

DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83

1 Answers1

1

The specified code looks to be working well as visible in the screenshot here: https://i.stack.imgur.com/MZX7G.jpg

Please check your code for other mistakes causing wrong behavior.

Rahul Shukla
  • 1,292
  • 9
  • 25