How to change Android EditText Cursor Color

You can change the Color of Android EditText View by creating a custom XML for the cursor,

1. Create a file custom_edit_text_cursor.xml under res/drawable folder,

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android=""
  android:shape="rectangle" >
    android:width="2dip" />
    android:color="@color/green" />

2. Now add attribute android:textCursorDrawable to your EditText View XML,


⚠️ Note: textCursorDrawable was introduced in Android SDK Level 12, hence you need to set minSDK level 12 or above for this to work! You may get a warning if you set minSDK level below API Level 12.

❗️ Attribute "textCursorDrawable" is only available in API level 12 and higher (current min is 8)

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.