grantland / android-autofittextview

A TextView that automatically resizes text to fit perfectly within its bounds.
Apache License 2.0
4.27k stars 688 forks source link

Use the CharSequence ( don't call to toString ) #14

Closed yogurtearl closed 10 years ago

yogurtearl commented 10 years ago

Right now, you are calling

        String text = getText().toString();

This makes AutoFitTextView not render Spannables correctly.

Instead, just do:

    CharSequence text = getText();

You can just use the CharSequence everywhere, e.g.:

  mPaint.measureText(text, 0, text.length())

Also, the StaticLayout constructor takes a CharSequence

grantland commented 10 years ago

I just tried this approach and Paint#measureText(String, int, int) didn't properly measure the widths of CharSequences with Spannables (Html.fromHtml("<b>test</b>")).

Would you know of another solution?

grantland commented 10 years ago

Should be fixed in 0.2.0