I'm using a TextView
that has a Spannable
object as the text and has multiple different text sizes. I want to know how do I get the text size at a specified index. If I use the TextView.getPaint()
and get the text size from there, it always uses the "default" size, which is just the text size that the textview is set to.
Figured it out. I used this code:
Spanned span = (Spanned) getText();
RelativeSizeSpan[] sizeSpans = span.getSpans( charStart, charEnd, RelativeSizeSpan.class );
If this array is not null, it gives a scalar from the default text size by calling getSizeChange()
, which I just multiply by the default text size to get my real text size.