grantland / android-autofittextview

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

I think there is a bug in AutofitHelper.java #41

Open THEONE10211024 opened 9 years ago

THEONE10211024 commented 9 years ago

I'm not for sure but I think the create() method in AutofitHelper.java, this line helper.setMinTextSize(minTextSize).setPrecision(precision); is not right. You should call setRawMinTextSize() rather than call setMinTextSize(). And I have reasons for this: I notice that getDimensionPixelSize() method returns size in pixel not in sp or dp, as we go deep inside, we can find that this method already converts sp to px! if you call setMinTextSize() method, you will convert it again! So I think this line should be changed to something like helper.setRawMinTextSize(minTextSize).setPrecision(precision); Am I right? Thank you!

grantland commented 9 years ago

Are you talking about this line here? https://github.com/grantland/android-autofittextview/blob/master/library/src/main/java/me/grantland/widget/AutofitHelper.java#L80

If what you're saying is correct, we get the pixel size via TypedArray.getDimensionPixelSize() and then pass that into AutofitHelper.setMinTextSize() with the unit TypedValue.COMPLEX_UNIT_PX. So we get the pixel size and state that it's the pixel size when reusing it. Am I completely missing the issue you're trying to convey?