Open pawelantczak opened 9 years ago
Use android:maxLines="2"
instead of android:singleLine="true"
.
Using maxLines="2" doesn't work because in AutofitHelper.autofit() you call getAutofitTextSize only if maxLines==1. I deleted this requirement in my subclass and it works.
It should work though, because I check that OR lineCount > maxLines here: https://github.com/grantland/android-autofittextview/blob/master/library/src/main/java/me/grantland/widget/AutofitHelper.java#L125
Is that returning something incorrect?
I see. For me the text was two words on a button, and the first word was too long, so it was chopped and the second part was added to the second line. The second line wasn't too long even so, so getAutofitTextSize was never triggered. So basically it doesn't work if a single word is longer than a line. We need a check for that.
@sehoi this doesn't seem to work on my side. The behavior is the same as if I set it in xml
@herrbert74 is right - it seems to happen when a single word is longer than a line.
Hello. What I want to achieve is exactly what is shown on animation. But, if I set
android:singleLine="true"
text never expands to second line. If single line is not set, resizing don't work.Even if I run your demo, text is always in one line. How to make it behave as on animated gif?