final StyleSpan bss = new StyleSpan(android.graphics.Typeface.BOLD);
final SpannableString ss = new SpannableString("How to " + text + " in " + type);
ss.setSpan(bss, 7, text.length() + 7, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
ss.setSpan(bss, 7 + text.length() + 4, ss.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView.setText(ss);
I want to make text and type BOLD. But only type is BOLD.
What did I miss?
According to the documentation :
setSpan(Object what, int start, int end, int flags)Attach the specified markup object to the range start…end of the text, or move the object to that range if it was already attached elsewhere.
A StyleSpan can only be used once in a Spannable. You need create a StyleSpan for each text and type
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With