Search code examples
androiduser-interfaceandroid-edittextuser-inputtextinput

EditText cursor overlapping last letter


On one of the devices I use for testing (HTC One S, in case it matters), the EditText cursor will overlap the last letter instead of being positioned just after the letter. In the attached screenshot, the black line is the actual cursor and the red line is where the cursor should be. This only happens when the cursor is at the last position; in other positions it appears correctly between letters (or before the first letter if at the very beginning).

enter image description here

I don't even begin to know what might be the problem here. Does anyone have an idea?


Solution

  • I solved this by doing the following:

    int flags = editText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG;
    editText.setPaintFlags(flags);