Open AndroidDeveloperLB opened 9 years ago
A possible workaround is to add a precision check for getAutofitTextSize :
if (RealTextView.DEBUG)
Log.d(TAG, "low=" + low + " high=" + high + " mid=" + mid +
" target=" + targetWidth + " maxLines=" + maxLines + " lineCount=" + lineCount);
if (lineCount > maxLines&&(high - low) >= precision) {
Also , add for "autofit" the part of setting the min size of the text font:
float low = minTextSize;
This causes a behavior that will actually permit more lines of text, but at least it won't crash...
Try this XML tag to be added to the sample's "view_activity_example_main.xml" file :
Then try to press ENTER twice inside the RealEditText.
The bug:it crashes. Here's the log:
FATAL EXCEPTION: main Process: org.hardsoft.real.textview, PID: 32379 java.lang.StackOverflowError at android.graphics.Paint.getTextRunAdvances(Paint.java:1842) at android.text.MeasuredText.addStyleRun(MeasuredText.java:164) at android.text.MeasuredText.addStyleRun(MeasuredText.java:204) at android.text.StaticLayout.generate(StaticLayout.java:281) at android.text.StaticLayout.(StaticLayout.java:140)
at android.text.StaticLayout.(StaticLayout.java:90)
at android.text.StaticLayout.(StaticLayout.java:68)
at android.text.StaticLayout.(StaticLayout.java:48)
at com.hardsoftstudio.real.textview.utils.AutofitHelper.getAutofitTextSize(AutofitHelper.java:151)
at com.hardsoftstudio.real.textview.utils.AutofitHelper.getAutofitTextSize(AutofitHelper.java:161)
...
And after this, I have the last line repeating itself.