android-autofittextview icon indicating copy to clipboard operation
android-autofittextview copied to clipboard

I think there is a bug in AutofitHelper.java

Open THEONE10211024 opened this issue 10 years ago • 1 comments

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!

THEONE10211024 avatar Jun 05 '15 05:06 THEONE10211024

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?

grantland avatar Jul 09 '15 05:07 grantland