TextView with different textSize

woyaru picture woyaru · Sep 12, 2011 · Viewed 67.6k times · Source

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?

Answer

Michele picture Michele · Sep 12, 2011

Try

span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);