I'm developing a new app where i need to customise EditText cursor colour and width of cursor. Can any one please guide me.It will be appriciable. Thanks in advance.
Asked
Active
Viewed 1.2k times
17
-
[http://stackoverflow.com/questions/11649234/change-edittext-cursor-color](http://stackoverflow.com/questions/11649234/change-edittext-cursor-color) – M D May 22 '15 at 11:36
-
http://stackoverflow.com/questions/6225995/can-i-change-the-cursor-size-in-android-edit-text-field – Abhishek Patel May 22 '15 at 11:38
2 Answers
35
Build your new drawable for cursor for example name it my_custom_cursor_drawable.xml in the drawable folder
my_custom_cursor_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<size android:width="0.5dp" />
<solid android:color="#FF0910DD"/>!--Could be any color you want
</shape>
The EditBox where you want this custom cursor set the property as
android:textCursorDrawable="@drawable/cursor_drawable"
Thats it !! improvise if need be. Any drawable , any shape etc...
2
You can define a custom drawable for the EditText Cursor and use it for EditText using android:textCursorDrawable
.

Paresh Mayani
- 127,700
- 71
- 241
- 295