Tuesday, 22 December 2020

SpannableStringBuilder setting String partially as bold not working

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



from SpannableStringBuilder setting String partially as bold not working

No comments:

Post a Comment