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

The min default text size isn't set correctly #23

Closed aaronvargas closed 9 years ago

aaronvargas commented 9 years ago

Expected Behavior: When you retrofit existing TextViews and change them to AutoFitTextViews in xml, they should resize correctly as more text is added to field.

Observed Behavior: TextViews changed to AutoFitTextViews Don't resize correctly to the Default min size (8sp)

Reproducible Test: In the project sample, remove the following line in main.xml autofit:minTextSize="8sp" see screenshot below

Reason: AutoFitHelper.java:66 int minTextSize = (int) helper.getMinTextSize(); AutoFitHelper.java:75 minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitTextView_minTextSize, minTextSize);

both of the returned sizes above are in Pixels...

AutoFitHelper.java:80 helper.setMinTextSize(minTextSize)

This method signature applies SP as no TypedUnit is specified. So, taking my density into account (xxhdpi) the density factor is 3. The min was/should be 24px but then the above method changed it to 72px

Proposed Solution: change AutoFitHelper.java:80 to helper.setRawMinTextSize(minTextSize); helper.setPrecision(precision);

autofit_not_resizing_correctly

vikskod commented 8 years ago

change AutoFitHelper.java:80 to helper.setRawMinTextSize(minTextSize); helper.setPrecision(precision);

ALSO not working