Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cursor not visible in EditText in Jelly Bean - this happens if you set a background for the field; to fix it, set the cursorDrawable to @null. Always use this combination when using custom backgrounds.
<EditText
android:id="@+id/my_edit_text"
...
android:background="@drawable/some_bg"
android:textCursorDrawable="@null" />
@GeorgCantor
Copy link

GeorgCantor commented Mar 23, 2018

thanks bro!

@turastory
Copy link

turastory commented Apr 2, 2018

What if I want to change the color of the cursor?? Here's what I'm using.

<EditText
    android:background="@null"
    android:textCursorDrawable="@color/coral"/>

This works in most of devices, but doesn't work on API 16. (Kitkat)
Any Ideas?

@turastory
Copy link

turastory commented Apr 2, 2018

Well I've searched for a while, and found a solution.
See this answer.
Use drawable instead of color for textCursorDrawable.

<EditText
    android:background="@null"
    android:textCursorDrawable="@color/coral"/>

@joshuapinter
Copy link

joshuapinter commented May 2, 2018

Holy shit, dude. That's been bugging me for years! Thanks for finding this out, it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment