I'm getting very strange behaviour with my TextView
. I can't seem to find the cause as most other issues with this stacktrace are to do with EditText
.
This is in my layout:
<TextView
android:id="@+id/transaction_card_scan_message_view"
android:layout_width="0dp"
android:layout_height="150dp"
android:elevation="2dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:lines="5"
android:textColor="@color/transaction_text"
android:textSize="@dimen/transaction_card_scan_title_textSize"
android:textAlignment="center"
android:textAllCaps="true"/>
I am getting this error:
2019-10-21 17:47:32.177 18455-18455/com.iaxept.contactless E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.iaxept.contactless, PID: 18455
java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getRunAdvance(Paint.java:2986)
at android.text.TextLine.handleText(TextLine.java:719)
at android.text.TextLine.handleRun(TextLine.java:873)
at android.text.TextLine.measureRun(TextLine.java:387)
at android.text.TextLine.measure(TextLine.java:277)
at android.text.TextLine.metrics(TextLine.java:251)
at android.text.Layout.getLineExtent(Layout.java:1094)
at android.text.Layout.drawText(Layout.java:383)
at android.widget.Editor.drawHardwareAccelerated(Editor.java:1903)
at android.widget.Editor.onDraw(Editor.java:1822)
at android.widget.TextView.onDraw(TextView.java:6691)
at android.view.View.draw(View.java:18319)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:666)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:672)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:780)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3112)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2908)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2502)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1509)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7051)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
I've tried messageView.setTransformationMethod(new AllCapsTransformationMethod(getParentActivity()))
to no avail. It's really strange as it works without issue when the text is a mix of lower and upper case and the stacktrace isn't exactly useful.
I believe this is an Android OS bug, as when I use toUpperCase()
in all of my setText()
or append()
calls there is no crash and therefore works as a temporary solution. However, the android:textAllCaps="true"
issue persists and needs to be fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With