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:
Hello there!,

You are using AdBlocker!

I am an independent developer trying to help fellow developers and students to resolve issues faced on a day-to-day basis, we 'Code to Care' . There is a lot of expenses involved in hosting and managing a website that's the reason we have ads.

A humble request to you to disable adBlocker on and support us pay our bills.

Cod2ecare - Line's of code for change.

To see contents reload page after unblocking
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.