Is this possible to set different textSize in one TextView? I know that I can change text style using:
TextView textView = (TextView) findViewById(R.id.textView);
Spannable span = new SpannableString(textView.getText());
span.setSpan(arg0, 1, 10, arg3);
textView.setText(span)
I know the range start...end of text I want to change size. But what can I use as arg0
and arg3
?
Try with AbsoluteSizeSpan
The complete code is:
I know very late to answer but people are still might have the same question.Even I struggled a lot on this. Suppose you have these two strings inside your strings.xml file
You now need to define two Style for them inside your style.xml with different textSize
Now from your Java file you need to use the spannable to load these two style and strings on single textView
Below is the formatStyles method which will return the formatted string after applying the style
Try