17

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.

Ritesh Kumar Singh
  • 344
  • 2
  • 3
  • 19
  • [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 Answers2

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...

Slava
  • 13
  • 1
  • 5
Uzair
  • 1,529
  • 14
  • 17
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