Crash on RealEditText when setting maxLines
Try this XML tag to be added to the sample's "view_activity_example_main.xml" file :
<com.hardsoftstudio.real.textview.views.RealEditText
android:id="@+id/w_rtv_example6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:maxLines="2"
android:padding="10dp"
android:text="@string/txt_example1"
android:textSize="30sp"
real:minTextSize="5sp"/>
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.
And after this, I have the last line repeating itself.
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...