Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change edit text cursor color and width in android

Tags:

android

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.

like image 849
Ritesh Kumar Singh Avatar asked May 22 '15 11:05

Ritesh Kumar Singh


2 Answers

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

like image 98
Uzair Avatar answered Nov 16 '22 16:11

Uzair


You can define a custom drawable for the EditText Cursor and use it for EditText using android:textCursorDrawable.

like image 24
Paresh Mayani Avatar answered Nov 16 '22 16:11

Paresh Mayani