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

Textview re-sizing issue #10

Open cody1024d opened 10 years ago

cody1024d commented 10 years ago

I am attempting to use your textview with it's height set as wrap-content within a fragment.

However, when the text is set BEFORE the text view is drawn (so in the fragment's onCreateView), the text gets resized, but the size of the TextView itself does not.

This ends up getting remedied the next time a sibling view is updated; resulting in a jarring UI experience as the textview all of a sudden shrinks to the correct size (moving the sibling views as well).

If the text is resized once the view is drawn, it works as intended. Have you experienced this issue before, and if so, do you have a workaround?

sehoi commented 8 years ago

For me, this worked.

// when resizing textview txtWord.setTextSize(10) AutofitHelper autofitHelper = AutofitHelper.create(txtWord); autofitHelper.setMaxLines(2); autofitHelper.setTextSize(txtWord.getTextSize());