Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of the cursor of an EditText in Android across all the sdk

I want to change the android's edittext cursor color on all devices. How do I do that?

like image 578
Kishore Avatar asked Jul 17 '12 13:07

Kishore


1 Answers

i had to use a drawable like this:

mycursor.xml:

      <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
        <size android:width="1dp" />
        <solid android:color="@android:color/holo_blue_light"/> 
<!--make sure its a solid tag not stroke or it wont work -->
    </shape>

in my edit text i set the cursor drawable attributes like this:

                            <EditText
                            android:id="@+id/et_details"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:cursorVisible="true"
                           android:textCursorDrawable="@drawable/mycursor"  
                            />
like image 115
j2emanue Avatar answered Sep 29 '22 05:09

j2emanue