[ACCEPTED]-Android Custom font Spannable Typeface Span-custom-font
Accepted answer
You are going to want to write a custom 2 TypefaceSpan. The good news is that they 1 aren't difficult. See here for an example.
You can do the following:
SpannableString spannableString = new SpannableString("your text");
Typeface typeface = Typeface.create(ResourcesCompat.getFont(this, R.font.your_font);
spannableString.setSpan(
new TypefaceSpan(typeface, Typeface.NORMAL)),
0, 4,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
This constructor 3 will replace the previous style of the text, achieving 2 what you want. However, the catch is that 1 it was introduced in API 28.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.