title: Android - EditText gives IndexOutOfBounds Exception while using textAllCaps
body: <p>I'm trying to create a very simple registration page using a relative layout. This registration page is linked to a fragment called RegistrationFragment.</p>
  
  <p>I have five EditText fields for this layout: name, phone number, email, password, and confirm password. For some reason, I can enter text into password and confirm password, but whenever I try to enter any text into the other fields, they immediately crash the application with an IndexOutOfBounds Exception.</p>
  
  <p>Here's the full stack trace:</p>
  
  <pre><code>java.lang.IndexOutOfBoundsException
          at android.graphics.Paint.getTextRunAdvances(Paint.java:1879)
          at android.text.TextLine.handleText(TextLine.java:747)
          at android.text.TextLine.handleRun(TextLine.java:898)
          at android.text.TextLine.measureRun(TextLine.java:414)
          at android.text.TextLine.measure(TextLine.java:293)
          at android.text.TextLine.metrics(TextLine.java:267)
          at android.text.Layout.getLineExtent(Layout.java:998)
          at android.text.Layout.drawText(Layout.java:329)
          at android.widget.Editor.drawHardwareAccelerated(Editor.java:1380)
          at android.widget.Editor.onDraw(Editor.java:1303)
          at android.widget.TextView.onDraw(TextView.java:5163)
          at android.view.View.draw(View.java:14465)
          at android.view.View.getDisplayList(View.java:13362)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
          at android.view.View.getDisplayList(View.java:13300)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
          at android.view.View.getDisplayList(View.java:13300)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
          at android.view.View.getDisplayList(View.java:13300)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
          at android.view.View.getDisplayList(View.java:13300)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
          at android.view.View.getDisplayList(View.java:13300)
          at android.view.View.getDisplayList(View.java:13404)
          at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
          at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
          at android.view.ViewRootImpl.draw(ViewRootImpl.java:2377)
          at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2249)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1879)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
          at android.view.Choreographer.doCallbacks(Choreographer.java:574)
          at android.view.Choreographer.doFrame(Choreographer.java:544)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
          at android.os.Handler.handleCallback(Handler.java:733)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5001)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>My xml layout file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#e5e5e5"&gt;
  
  &lt;TextView
      android:id="@+id/fragment_registration_title"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="@dimen/activity_vertical_margin"
      android:layout_marginTop="@dimen/activity_vertical_margin"
      android:layout_marginRight="@dimen/activity_horizontal_margin"
      android:layout_marginLeft="@dimen/activity_horizontal_margin"
      android:text="@string/registration_title"
      android:textAllCaps="true"
      android:textSize="35sp"
      android:layout_centerHorizontal="true"
      android:textColor="@color/blue"
      /&gt;
  
  &lt;RelativeLayout
      android:id="@+id/fragment_registration_edit_text_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="30dp"
      android:layout_marginRight="30dp"
      android:layout_below="@id/fragment_registration_title"
      android:layout_centerHorizontal="true"&gt;
  
      &lt;EditText
          android:id="@+id/fragment_registration_legal_name"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:hint="@string/full_name_prompt"
          android:maxLines="1"
          android:textAllCaps="true"
          android:background="@drawable/edit_text_top_rounded"
          /&gt;
  
      &lt;EditText
          android:id="@+id/fragment_registration_cell_phone"
          android:layout_below="@id/fragment_registration_legal_name"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:hint="@string/cell_phone_prompt"
          android:maxLines="1"
          android:textAllCaps="true"
          android:background="@drawable/edit_text_white"
          /&gt;
  
      &lt;EditText
          android:id="@+id/fragment_registration_email"
          android:layout_below="@id/fragment_registration_cell_phone"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:hint="@string/email_prompt"
          android:maxLines="1"
          android:textAllCaps="true"
          android:background="@drawable/edit_text_white"
          /&gt;
  
      &lt;EditText
          android:id="@+id/fragment_registration_password"
          android:layout_below="@id/fragment_registration_email"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:hint="@string/confirm_password_prompt"
          android:maxLines="1"
          android:background="@drawable/edit_text_bottom_rounded"
          /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;Button
      android:id="@+id/fragment_registration_button"
      android:background="@drawable/button_registration"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/registration_button"
      android:textColor="#ffffff"
      android:layout_below="@+id/fragment_registration_edit_text_layout"
      android:layout_marginTop="5dp"
      android:layout_marginLeft="30dp"
      android:layout_marginRight="30dp"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>If relevant, I'm "looking" at my Fragment code using the below, which is at the end of the onCreate() method of my main activity for testing purposes. I got the same errors when I tried testing Registration as an activity though.</p>
  
  <pre><code>RegistrationFragment test = new RegistrationFragment();
  setContentView(R.layout.fragment_registration);
  </code></pre>