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)

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap